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

Union show hole as multipolygon #71

Closed
samneefs opened this issue Mar 9, 2018 · 3 comments
Closed

Union show hole as multipolygon #71

samneefs opened this issue Mar 9, 2018 · 3 comments

Comments

@samneefs
Copy link

samneefs commented Mar 9, 2018

When I arrange multiple polygons in a way so that they should form a polygon with a hole, the resulting geoJson is formated as if the hole is another polygon in the multipolygon
[
[ [ outer polygon ] ],
[ [ inner polygon/hole ] ]
]
Whereas it should be
[
[ [ outer polygon ],
[ inner polygon/hole ] ]
]
I have an example (strangly it shows correct, in the viewer, but with F12 you'll see the wrong geoJson
https://codepen.io/Sakke/pen/aYbeEM?editors=0010

The following example is related and does show the error in the viewer:
When I add an additional polygon (making it a true multipolygon), then I also goes wrong.
https://codepen.io/Sakke/pen/dmPoMp?editors=0010

@samneefs
Copy link
Author

samneefs commented Mar 9, 2018

I was trying to find the reason and it seems to be with if(!resultEvents[i].isExteriorRing)
the original is an exterior ring, and because of that isExteriorRing=true.
Then it does result.push(contour) where I guess it should have done result[result.length - 1].push(contour[0]);
However I have no idea how I could validate it otherwise. Maybe with a method where I can check if one polygon is completely contained in the other, then I could make it a hole. However that would seem to be a workaround.

@samneefs
Copy link
Author

It seems this is inherent to the Martinez algorithm: you still have to figure out which polygon is a hole and to which polygon the hole belongs.
In my code I sweep trough the polygons to try and figure this out, however my implementation probably isn't quite performant.

@rowanwins
Copy link
Collaborator

Resolved by #113

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

No branches or pull requests

3 participants