benbovy / spherely

Manipulation and analysis of geometric objects on the sphere.
https://spherely.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
119 stars 8 forks source link

Add bindings (top-level "ufuncs") for predicates, measurement, etc. #17

Open benbovy opened 1 year ago

benbovy commented 1 year ago

Some features available in s2geography that could be implemented in spherely with relatively little effort (i.e., straightforward functions returning simple types like bool, float, etc.):

Predicates:

Measurement:

One example with intersects

s2geography API:

https://github.com/paleolimbot/s2geography/blob/764682d60f757383e5853a45a12404c84f3e5961/src/s2geography/predicates.h#L10-L12

spherely bindings:

https://github.com/benbovy/spherely/blob/e874e6091888db6c09d9aee79c3ff260224f635b/src/predicates.cpp#L37-L51

For predicates that are not directly implemented in s2geography but that can be easily derived from another predicate, it is possible to use a lambda, like for within:

https://github.com/benbovy/spherely/blob/e874e6091888db6c09d9aee79c3ff260224f635b/src/predicates.cpp#L84-L100

Documentation:

https://github.com/benbovy/spherely/blob/main/docs/api.rst#predicates

Typing annotations:

https://github.com/benbovy/spherely/blob/0b7d3bbcce1dffbff9e283f6e15ff5c3497e26de/src/spherely.pyi#L104