Comments (15)
Can you reproduce the inversion from the screenshot alone? Or would it help if I tried to create a reduced test case?
from d3-geo-polygon.
It's just a question of fiddling with the mouse and then printing projection.rotate()…
A bad case:
projection = d3.geoAirocean().rotate([88, -37.8, -73.2])
https://observablehq.com/d/7c5b4f1ff5a76024
from d3-geo-polygon.
And
projection.rotate([-70.2, -47, -121.6])
creates an inversion of land and ocean
from d3-geo-polygon.
Another inversion: https://observablehq.com/d/303582dda96b0649
from d3-geo-polygon.
I've updated the notebook to only show the offending polygon (and added the ability to step through all polygons).
from d3-geo-polygon.
from d3-geo-polygon.
I've fixed the problematic point in https://unpkg.com/[email protected]/
(see visionscarto/world-atlas@590dbeb), and it fixes the inversion problem.
from d3-geo-polygon.
Looks like I finally nailed that bug. There is a case where we would rejoin with a line if the segment's first and last points were coincident. But the test for coincidence used a very tolerant pointEqual, and two points seperated by 1e-6 were considered equal, and they were rejoined directly, creating this "bleeding". Fixed at a08a09e
Test here: https://observablehq.com/d/7c5b4f1ff5a76024
(EDIT - Dec. 2019: the bug is still here — looks like I forgot to merge the change)
from d3-geo-polygon.
We still get some inversions on the example, but I'm having a hard time isolating them.
from d3-geo-polygon.
What's your process and intuition to narrow them down?
from d3-geo-polygon.
To find the problematic rotations I have no method, I just rotate the airocean globe until I see a flash of black (if such a thing exists). If I'm lucky to find one, I can just type projection.rotate()
in a cell to read the values.
To find the faulty code, my method in this case is a bit like what you did in the notebook: I remove as much "matter" as I can from the polygons, and try to get to (ideally) a faulty triangle or a polygon with very few edges.
Then I write two test cases in node, one with the faulty rotation, the other with a different rotation, which is ideally very close to the faulty one, but does not break.
After that, I start to edit the src code, adding console.warn() where I suspect there might be a difference, and run the two test cases side by side. The numbers change a bit, but I'm looking for places where the structure is different. In the case of a08a09e, I ended up at this specific line of code, and saw that the pointEqual test was suddenly saying true and triggered the bug.
from d3-geo-polygon.
What assumptions can be made about the inversions so far? E.g.:
- Are they limited to certain types of projections?
- Are they guaranteed to be caused only by a faulty geometry? What kind of faults (e.g. overlaps/intersections)?
- Will the inversion only be triggered by lines that get cropped by the projection's sphere?
from d3-geo-polygon.
from d3-geo-polygon.
Not sure if related or relevant: compareIntersection appears to apply some fuzz via epsilon.
Related issue: #3
from d3-geo-polygon.
Closing for now, as bleeding issues are solved. If we can find an inversion we'll open a new issue.
from d3-geo-polygon.
Related Issues (20)
- fix HEALPix? HOT 1
- faster Voronoi projection
- Roşca-Plonka projection?
- Can this library be used with other projections? HOT 4
- [Cahill-Keyes] Conformal version HOT 3
- Use clipPolygon for geoInterrupted HOT 2
- Multiple broken links in examples HOT 6
- d3.geoVoronoi() is not (yet) existing? HOT 1
- MultiPolygon clipping HOT 3
- Easier usage with d3.geoProject? HOT 2
- named imports fail in webpack build. HOT 2
- planar polygon clipping HOT 1
- South aspect of Lee’s conformal projection in a tetrahedron is all black HOT 4
- use robust-predicates?
- clipping bug
- Node >10.17.0 support HOT 6
- Markley
- Inverse clipping on d3.geoClipPolygon HOT 2
- Tetrahedral Lee: Inverse broken? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3-geo-polygon.