d3-geo-projection icon indicating copy to clipboard operation
d3-geo-projection copied to clipboard

geoProject converts hole to MultiPolygon

Open ondras opened this issue 5 years ago • 2 comments

As shown here: https://observablehq.com/@ondras/d3-geoproject-problem (resulting MultiPolygon has two distinct exterior-only polygons)

The simple GeoJSON feature is a triangle-shaped polygon with a smaller triangle-shaped hole. The problem is caused by a vertex that is shared between the hole and the outer boundary.

For comparison, the feature_good has the hole's problematic vertex shifted a tiny bit away from the exterior (towards the center) - and the geoProject call correctly preserves the hole.

ondras avatar Oct 07 '20 13:10 ondras

I believe(d) this is considered "degenerate" in GeoJSON (but I admit I haven't been able to find a source).

However there is necessarily a discontinuity: if you allow that coordinate 47 to vary continuously as 47+x, it will go from "Polygon" for x < 0 to "MultiPolygon" for x > 0.

Fil avatar Oct 08 '20 05:10 Fil

However there is necessarily a discontinuity:

I am okay with a discontinuity. I would just like to receive a "Polygon" for x==0.

Alternatively, this particular case can also return one polygon (five vertices, six edges), removing the hole from the exterior polygon (and using the problematic vertex twice). I suppose this would work as well.

ondras avatar Oct 08 '20 07:10 ondras