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:
transform the lat/lon to ECEF vectors
project the coordinates onto a plane perpendicular to the centroid vector of the ring
transform the projected coordinates into a (2d) cordinate system perpendicular to the centroid vector
determine the signed area of the transformed polygon with shoelace formula
if the signed area>0, the polygon is CCW
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
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 ifforce_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