d3 / d3-geo-projection

Extended geographic projections for d3-geo.
https://observablehq.com/collection/@d3/d3-geo-projection
Other
1.1k stars 201 forks source link

Allow spherical winding of polygons in geoProject. #185

Open Fil opened 4 years ago

Fil commented 4 years ago

Context: geoProject rewinds polygons to put them in the correct order as [outer ring, …holes], creating MultiPolygons as necessary. This is the desired (and semi-documented) behavior, however it precludes using geoProject with transforms that map spherical geometries to the sphere.

This change allows to specify, with an optional spherical boolean flag, that the transform returns spherical coordinates. We can then call the relevant polygon winding algorithms: geoContains and a test on geoArea replace the planar contains and clockwise functions to determine is a ring is an outer ring or a hole.

For clarity, the change is kept minimal in this commit, but before we merge I will reformat it (whitespace).

An older tentative was at: https://github.com/d3/d3-geo-projection/pull/146