Skip to content

Conversation

@icetan
Copy link

@icetan icetan commented Mar 7, 2013

To determine if a polygon has multiple parts with or without holes I walk each ring and each time a clockwise ring is parsed it is added as a new polygon part. Each time a counter-clockwise ring appears it is added to the previously parsed clockwise ring and forms only one polygon together with holes.

If there is more than one clockwise ring in a feature the geometry type is set to "MultiPolygon".

I used this this file as reference (page nr. 8): http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf

@icetan
Copy link
Author

icetan commented Mar 7, 2013

I realized that there might be a problem with this tough.

Rings in a polygon stored in a Shape-file may occur in any order. If a counter-clockwise ring occurs in the wrong order and does not reside inside the previously parsed clockwise ring the counter-clockwise ring will be added incorrectly as a hole to the previous polygon part.

The only way to split the rings into separate GeoJSON polygons correctly and combine them into a multipolygon, that I can see, is to check intersection between the rings. This is a costly process though but the GeoJSON spec. says that each ring following the first in a polygon must be interior rings or holes.

Anyway this is something to think about and improve on in the future.

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 this pull request may close these issues.

1 participant