-
Notifications
You must be signed in to change notification settings - Fork 560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API: what should is_ccw return for non rings / polygonal input? #1696
Comments
I've implemented |
@jorisvandenbossche I think that #1690 also solves most of the issues you raised in your comment above. |
Adding support for polygons seems like a good idea, and dropping support for LineStrings seems reasonable given issues of self-intersections causing problems around determining orientation. Adding Instinctively, keeping |
Returning |
We had discussed that in pygeos #201(comment) and ruled out |
The question that also comes up here, is that if we support Polygon, then what about GeometryCollections that include a Polygon? |
Why won't we? |
Sorry, I should have clarified: I would find it inconsistent that if |
Oh, I got confused and actually referred to |
It seems like it should always be Otherwise, |
I think that |
The
is_ccw
function was implemented in pygeos/pygeos#201, and there was actually already some discussion about that at the time as well (pygeos/pygeos#201 (comment)).This function is new in 2.0.0 (there was already a Linearring.is_ccw attribute as well, but that would not be affected by this issue).
We implement
is_ccw
based on GEOS'GEOSCoordSeq_isCCW
, which works on individual coordinate sequences (not geometries) and makes some assumptions (eg that the sequence is closed).As a consequence, some of the additional logic to work with geometries is implementated on our side (impl in ufuncs.c).
Some aspects of the current (documented) behaviour:
If we compare this behaviour with for example the PostGIS equivalent
ST_IsPolygonCCW
:Of course this function is a bit different, since it is focused on Polygons (and doesn't consider even LinearRings, but this might be because PostGIS in general tries to avoid directly exposing LinearRing, eg ST_ExteriorRing also returns a LineString instead of LinearRing).
Based on the above, some API design questions to consider:
is_cw = ~is_ccw(..)
). For that reason, we should maybe consider adding ais_cw
as well? (postgis also has both)True
instead ofFalse
for non-linear inputs? (i.e. follow the postgis behaviour) This might depend on the use case what is most useful. But for example, if you would like to useis_ccw
to check that all your geometries are correctly oriented (for an application that requires all rings to be CCW), you actually want True to be able to useis_ccw(input_geometries).all()
, since non-linear/polygonal geometries don't have a orientation and thus are always fine (currently one would need to dois_ccw(input_geometries[np.isin(get_type_id(input_geometries), [2, 3]]).all()
, assuming that polygons are handled)Lastly, if we are going to add a
force_ccw
function (#1366), it would also be nice that those two are consistent with each other (for example ifforce_ccw
would re-orient rings and polygons (and not LineStrings), ideally alsois_ccw
would check those types).Since
is_ccw
is a new function in 2.0.0, I think we could still consider quickly tweaking the default behaviour a bit in 2.0.1cc @caspervdw @brendan-ward
The text was updated successfully, but these errors were encountered: