d3-geo-projection
d3-geo-projection copied to clipboard
geoProject converts hole to MultiPolygon
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.
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.
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.