sidewalklabs / s2sphere

Python implementation of the S2 geometry library.
http://s2sphere.sidewalklabs.com/
MIT License
213 stars 44 forks source link

Fix tangent projection #34

Open andrewtapay opened 6 years ago

andrewtapay commented 6 years ago

I think there's a typo in the helper function CellId.uv_to_st in the case that CellId.PROJECTION == 1 (the tangent projection). To wit: this should be an increasing function that maps [-1, 1] to [0, 1], and in the default case it does. For example:

>>> import s2sphere
>>> s2sphere.CellId.uv_to_st(-1)
0.0
>>> s2sphere.CellId.uv_to_st(1)
1.0
>>>

However, if we use the tangent projection, this isn't the case:

>>> s2sphere.CellId.PROJECTION = 1
>>> s2sphere.CellId.uv_to_st(-1)
-0.39269908169872414
>>>

I think this PR resolves the issue. Indeed, this function now matches the analogous function in the original C++ library.


This change is Reviewable