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

Fix direction of Polygon ring coordinates #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cdbax
Copy link

@cdbax cdbax commented Oct 5, 2019

The shapefile specification (pg.8) has some concrete requirements for the order of vertices for polygon rings:

The order of vertices or orientation for a ring indicates which side of the ring is the interior of the polygon. The neighborhood to the right of an observer walking along the ring in vertex order is the neighborhood inside the polygon. Vertices of rings defining holes in polygons are in a counterclockwise direction.

The geojson specification requires the opposite orientation:

A linear ring MUST follow the right-hand rule with respect to the area it bounds, i.e., exterior rings are counterclockwise, and holes are clockwise.

This change ensures that rings will be defined in the correct orientation based on whether it is an internal or external ring.

@sheindel
Copy link
Contributor

Hi @cdbax! Thanks so much for putting this together!

I'm sorry this hasn't been addressed in so long. I've been slowly trying to resurrect this repo.

Your implementation mostly makes sense, but I'm curious: Have you used/are still using this fix in production? Or was this a theoretical change?

@cdbax
Copy link
Author

cdbax commented Aug 23, 2023

It was used in production at the time to address an active problem we had, and it worked. I'm no longer with that company now, so can't say if it's still being used.

I was very new to programming when I wrote this, so I will not be at all offended if you need to modify/improve it.

Thanks for reaching out after so long. It will be great to see this repo get some love again. It's a great resource.

@charlieforward9
Copy link
Contributor

It would be nice to see the polygon ring coordinates function correctly as the company I am working for has an upcoming feature that will use these polygon structures.

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.

3 participants