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

Unexpected error: Unable to find a ring sample point #205

Closed
sebhinck opened this issue Sep 18, 2020 · 3 comments
Closed

Unexpected error: Unable to find a ring sample point #205

sebhinck opened this issue Sep 18, 2020 · 3 comments

Comments

@sebhinck
Copy link

Hi,
after the update from 2.1.0 to 2.1.2 I am getting errors for some Polygons when I try to access the __geo_interface__:
Unexpected error: Unable to find a ring sample point
I guess it is related to 2d207e2

It might be related to holes in the Polygon, but I couldn't figure out why for some there is an error and for some there is no problem.

I create the polygons using the Shapely package. Here is a shapefile containing one example Polygon that fails: poly_fail.zip

Maybe this helps you finding the problem!

Thank you for providing this great tool!

@sebhinck
Copy link
Author

I might have solved the problem.
It seems that my input polygon was corrupted. There were polygons overlapping others. If I fix this everything seems to work.

I'm closing it again..

karimbahgat added a commit that referenced this issue Sep 28, 2020
In trying to find a sample point, we iterate the ring's triplet coordinates and add add the second coord from the end to allow checking the last triplet. Previously the second coordinate was added by changing the main coords list in-place, but that messes with the point-in-polygon algorithm. Fixed by only iterating through the points instead of changing the coords list.
Fixes #205.
@karimbahgat
Copy link
Collaborator

Glad that you were able to solve your problem, and yes overlapping polygons in a multipolygon would be considered invalid. However, after looking at your example file, the bug you encountered highlighted an actual problem with the hole-in-polygon code when it tries to find a sample point for a hole. It was a simple bug where the list of the hole coordinates was inadvertedly given an extra coordinate, which messed with the point-in-polygon test for short simple polygons as you had in your example file. Anyway, added a bug fix for that now, so thanks for stumbling across this!

@sebhinck
Copy link
Author

Ok, great you found and fixed a bug!

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