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

intersection of polygon with hole results in the hole flipping orientation and causing self-intersection #128

Open
mglasgow opened this issue May 3, 2020 · 2 comments · May be fixed by #148

Comments

@mglasgow
Copy link

mglasgow commented May 3, 2020

I have found another edge case while dividing up OpenStreetMap country boundaries into QuadTiles.

I have attached the geojson in the "genericTestCase" format that @bluenote10 put together.

I am intersecting a polygon of Spain's border, which has an enclave cut out for Gibraltar, with a square tile. The Gibraltar hole is completely contained within the square tile, so should be a straight forward intersection.

This is what I expect:
expected result

This is what I get. Note the internal hole is coloured red, as it is now a part of the multipolygon

actual result

Here are is the generic test case geojson:

issue128.geojson.txt

And here is the actual geojson result I get from the intersection:

actual-output.geojson.txt

Perhaps the winding order of the interior ring is reversing?

I am using the master branch of this repo, and I have also applied the #125 pull request too.

@bluenote10 If you get a chance, would you mind running this through your Rust implementation to see how it handles it?

@bluenote10
Copy link
Collaborator

Indeed, this shows up on Rust side as well:

image

Need to have a closer look -- looks indeed like a straightforward case.

@mglasgow
Copy link
Author

mglasgow commented May 4, 2020

Thanks for confirming this is a bug. I have a workaround I am using at the moment. For polygons which have interior holes, I am now running intersect manually on each of the rings of the polygon. I then combine the results by using Diff to subtract the interior rings from the outer ring. This is working well, except for an issue where Diff doesn't seem to set the orientation of holes properly. I have raised a separate issue for this (#129) and am manually correcting the orientation for interior rings.

@rowanwins rowanwins linked a pull request Apr 4, 2022 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants