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
Hi,
I am getting incorrect results for Multipolygon contains, which seem to be related to earthly hemispheres...
I have reduced my problem to a code example at the bottom. I began with an array of Multipolygons, and have systematically cut it back to two triangular "nations", one in the northern and one in the southern hemisphere.
I am getting inexplicable behaviour with the one situated in the southern hemisphere, and I can't understand what exactly could be going wrong.
I also added a quick sanity check below, which uses the single polygon contains method provided by d3-polygon.
I ran the below code using:
npm i d3-geo d3-polygon && node testd3.js
If you have any further questions, please feel free to contact me, or point out my ignorance 😄🥇
Thanks in advance
jake
Note these versions:
d3-polygon: 1.0.6
d3-geo: 1.11.9
While planar polygons are not ambiguous re: what is inside and what is outside, for spherical polygons there must be a rule. In D3 the rule is that polygons are defined as "clockwise". A better metaphor than the "clock" is that, if you walk along the border, "inside" the polygon is under your right foot (see #138 (comment) for a great picture of myself trying out geoContains in a special suit).
It appears that your southern geometry is running in the "wrong" winding order, which means that the surface it occupies is "all the globe except the small triangle". You can verify this by computing d3.geoArea(geometry): it's almost equal to the globe's surface (4π).
Hi,
I am getting incorrect results for Multipolygon contains, which seem to be related to earthly hemispheres...
I have reduced my problem to a code example at the bottom. I began with an array of Multipolygons, and have systematically cut it back to two triangular "nations", one in the northern and one in the southern hemisphere.
I am getting inexplicable behaviour with the one situated in the southern hemisphere, and I can't understand what exactly could be going wrong.
I also added a quick sanity check below, which uses the single polygon contains method provided by d3-polygon.
I ran the below code using:
npm i d3-geo d3-polygon && node testd3.js
If you have any further questions, please feel free to contact me, or point out my ignorance 😄🥇
Thanks in advance
jake
Note these versions:
d3-polygon: 1.0.6
d3-geo: 1.11.9
The text was updated successfully, but these errors were encountered: