spherely icon indicating copy to clipboard operation
spherely copied to clipboard

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

Open benbovy opened this issue 3 years ago • 0 comments

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:

  • [x] intersects
  • [x] equals
  • [x] contains
  • [ ] touches
  • [x] within (#18)
  • [x] disjoint (#18)
  • [ ] covers
  • [ ] covered_by

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

benbovy avatar Mar 08 '23 08:03 benbovy