You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue in vega/vega#2572 seems to be due to a clip circle problem when faced with a degenerate polygon.
https://observablehq.com/d/5380dd24622eca74 shows a reduced test case, with a (south) polar cap expressed as a polygon that has a line pluging to the south pole then coming back up.
(Note that, though this looks like a "fringe" case but this type of degeneracy can be quite common when using certain types of GeoJSON; for instance, in the vega example, it's due to geometries produced by a rectangular contour analysis. In the wild, a lot of GeoJSON files are similarly constrained to [-180,180] longitudes.)
A rectangular projection shows the polar cap in gray ((north pole in red):
with any d3 azimuthal projection centered on the north pole, the south pole is projected to the circumference of the sphere. clipAngle(170) ensures that we don't reach this "point" by limiting the projection to latitude -80°.
The issue in vega/vega#2572 seems to be due to a clip circle problem when faced with a degenerate polygon.
https://observablehq.com/d/5380dd24622eca74 shows a reduced test case, with a (south) polar cap expressed as a polygon that has a line pluging to the south pole then coming back up.
(Note that, though this looks like a "fringe" case but this type of degeneracy can be quite common when using certain types of GeoJSON; for instance, in the vega example, it's due to geometries produced by a rectangular contour analysis. In the wild, a lot of GeoJSON files are similarly constrained to [-180,180] longitudes.)
A rectangular projection shows the polar cap in gray ((north pole in red):

with any d3 azimuthal projection centered on the north pole, the south pole is projected to the circumference of the sphere. clipAngle(170) ensures that we don't reach this "point" by limiting the projection to latitude -80°.
As you can see from the two next images, adding 1e-6 to one of the polygon's vertices makes the drawing "flip".
without epsilon:

with epsilon:

It looks like this is due to the test at https://github.com/d3/d3-geo/blob/master/src/clip/rejoin.js#L25 concluding that we have two closed rings, and dropping the case for "rejoining by interpolating along the clip edge".
A quick fix is to trick the algorithm out of thinking these are closed rings, by adding an epsilon in https://github.com/d3/d3-geo/blob/master/src/clip/circle.js#L83 ; it works in the test case and in the vega example, but this might lead to unexpected bugs somewhere else.
The text was updated successfully, but these errors were encountered: