Skip to content
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

Allow constructing a Polygon(..) with repeated first / last coordinate pair #42

Open
jorisvandenbossche opened this issue Aug 30, 2024 · 2 comments

Comments

@jorisvandenbossche
Copy link
Collaborator

Currently we get:

In [35]: spherely.Polygon([(0, 0), (1, 1), (0, 1), (0, 0)])
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[35], line 1
----> 1 spherely.Polygon([(0, 0), (1, 1), (0, 1), (0, 0)])

ValueError: loop is not valid: Edge 3 is degenerate (duplicate vertex)

I am used from shapely that explicitly passing the closing point (which is the same as the first point) is allowed (also because the GEOS data model actually stores this in the coordinates), but this currently fails in spherely.
Also because things like WKT or GeoJSON show this, I think it is a common pattern to pass this.

We can probably detect that the last coordinate pair is the same as the first and drop it for the user.

@benbovy
Copy link
Owner

benbovy commented Oct 11, 2024

In #51 both closing vs. non-closing are supported, although this is fragile as it relies on strict equality of the 1st and last computed vertices (S2Point). We'll certainly need to revisit that as well as uniformize the API with #49 and #50 (i.e., add oriented and planar arguments).

@jorisvandenbossche
Copy link
Collaborator Author

although this is fragile as it relies on strict equality of the 1st and last computed vertices (S2Point).

I think that is fine (at least for now), AFAIK in GEOS / shapely we also rely on exact floating point equality (that can give problems in corner cases, eg after transforming coordinates, but it's not that common)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants