SpatioTemporal / STAREPandas

STAREpandas adds SpatioTemporal Adaptive Resolution Encoding (STARE) support to pandas DataFrames. https://starepandas.readthedocs.io/en/latest/
MIT License
4 stars 1 forks source link

Fix for CCW detection #162

Closed NiklasPhabian closed 5 months ago

NiklasPhabian commented 9 months ago

Since Shapely does not understand geographic coordinates, it has no way of certainly telling if a ring is CCW or CW if it crosses the singularity or discontinuity at the antimeridian or the poles.

I added a routine to (more) robustly determine CCW. In short:

This should work regardless of how many times a ring crosses the antimeridian or encircles one of the poles. 100% sure there are edgecases where this attempt fails, but it beats the current setup.

Note that sids_from_ring() now always will use this routine. We will invert the order of a ring if force_ccw and not ring_is_ccw(ring):

I added tests in `tests/test_intersects'. If we encounter any polygon/ring that breaks the routine, we should add it to the test