Skip to content

[convert] Ensure winding order of polygon linear rings#28

Open
mickmis wants to merge 1 commit intomainfrom
8/ensurewindingorder
Open

[convert] Ensure winding order of polygon linear rings#28
mickmis wants to merge 1 commit intomainfrom
8/ensurewindingorder

Conversation

@mickmis
Copy link

@mickmis mickmis commented Mar 12, 2026

Fix focagis/geoawareness-cis#8

Issue: linear rings of some polygons in the original ed269 do not respect the right-hand rule as specified by https://datatracker.ietf.org/doc/rfc7946/ section 3.1.6.

With the changes in this PR we ensure that the winding order do respect this rule.
We do so by using the Shoelace formula to determine whether the coordinates are specified clockwise or counter-clockwise, and reverse them if that is necessary.

The output of the converter for the FOCA files generated locally may be found in this gist. Checking manually e.g. the 'GE32' airspace seems to yield correct result.

@mickmis mickmis force-pushed the 8/ensurewindingorder branch from 365cb49 to a18b8a9 Compare March 12, 2026 15:52
type="Polygon",
coordinates=hp.coordinates if "coordinates" in hp else None,
coordinates=ensure_polygon_rings_winding_order(hp.coordinates)
if "coordinates" in hp and hp.coordinates is not None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work if hp.coordinates is []? (seems like it might crash) Perhaps:

Suggested change
if "coordinates" in hp and hp.coordinates is not None
if "coordinates" in hp and hp.coordinates

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.

Geozone invalid geometries

2 participants