Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

S2Sphere is slow for certain operations #25

Open
thehesiod opened this issue Jul 21, 2016 · 0 comments
Open

S2Sphere is slow for certain operations #25

thehesiod opened this issue Jul 21, 2016 · 0 comments

Comments

@thehesiod
Copy link
Contributor

We have a python wrapper around https://code.google.com/archive/p/s2-geometry-library/ and I just ran some tests converting lat/lon to a given S2 Cell Level:

def s2sphere_latlon_lvl(lat, lon, level):
    latLon = s2sphere.LatLng.from_degrees(lat, lon)
    c = s2sphere.CellId.from_lat_lng(latLon)
    par = c.parent(level)
    token = par.to_token()
    return token


def s2_latlon_lvl(lat, lon, level):
    s2id = format(s2.base.latlon_to_s2id(lat, lon, level, level)[level], '016x').rstrip('0')
    return s2id

results:

__main__.s2sphere_latlon_lvl: elapsed:8.59s o/s:34917.09 iterations:300000
359a89ec
__main__.s2_latlon_lvl: elapsed:0.56s o/s:538245.00 iterations:300000
359a89ec

looking at a perf trace, most of the time is spent in from_lat_lng

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant