Comments (9)
Excellent remark. Would you mind sending a PR?
from d3-geo-voronoi.
I also had to fix the others, now with google maps all this works without any change:
map.data.addGeoJson(voronoi.links())
map.data.addGeoJson(voronoi.polygons())
map.data.addGeoJson(voronoi.hull())
map.data.addGeoJson(voronoi.triangles())
Unfortunately polygons is still not working correctly / not compliant because it is not respecting the right-hand rule.
You can validate the output for example at: http://geojsonlint.com/
This is a problem for the basic case where you have 2 points, so both polygons will have the same coordinates, but they enclose opposite globe areas.
I think you should take a look at it, because fixing it will probably break other (non-conformant) applications.
from d3-geo-voronoi.
As per RFC 7946:
3.1.6. Polygon
To specify a constraint specific to Polygons, it is useful to
introduce the concept of a linear ring:o A linear ring is a closed LineString with four or more positions.
o The first and last positions are equivalent, and they MUST contain
identical values; their representation SHOULD also be identical.o A linear ring is the boundary of a surface or the boundary of a
hole in a surface.o A linear ring MUST follow the right-hand rule with respect to the
area it bounds, i.e., exterior rings are counterclockwise, and
holes are clockwise.
from d3-geo-voronoi.
Also mind that Sphere is not valid type (geometry.type = "Sphere";).
And the bug I'm seeing might be also due to:
3.1.9. Antimeridian Cutting
In representing Features that cross the antimeridian,
interoperability is improved by modifying their geometry. Any
geometry that crosses the antimeridian SHOULD be represented by
cutting it in two such that neither part's representation crosses the
antimeridian.For example, a line extending from 45 degrees N, 170 degrees E across
the antimeridian to 45 degrees N, 170 degrees W should be cut in two
and represented as a MultiLineString.
from d3-geo-voronoi.
It seems that part of this issue, or all of it, might be to a non-compliante on Google Maps. I just filled the bug with the team:
https://issuetracker.google.com/issues/63581224
from d3-geo-voronoi.
Yes the {type: "Sphere"}
representation is specific to d3-geo (see https://gis.stackexchange.com/questions/42681/how-do-i-represent-the-whole-earth-as-a-polygon).
I don't think d3-geo-voronoi should cut shapes across the antimeridian — maybe add a clipper in your application when it's needed. It's one of those infuriating rules :)
As for the coding style, let's try and stick to d3's style as much as possible.
from d3-geo-voronoi.
I think Sphere was used because of the lack of the right hand rule, which didn't exist initially on GeoJSON. But for me I don't care for the Sphere or antimeridian cutting case, but following the right hand rule is quite important, as otherwise the polygons created are ambiguous (and they fail GeoJSON linting).
from d3-geo-voronoi.
I'm not sure if your comment about the right-hand rule implies that there is still a bug? I think we're good, but I might be wrong :) If that's the case please open an issue.
from d3-geo-voronoi.
Yes. The output json still fails GeoJSON linting due to violating the right hand rule. I'll open a issue with tests or examples later today, since fixing it might be over my league.
from d3-geo-voronoi.
Related Issues (20)
- Numeric stability HOT 8
- Geo Voronoi polygons out of triangles HOT 4
- Move to Delaunator@3 HOT 2
- return a clean triangulation HOT 4
- geoHeatmap
- long edges?
- No geoContour in v1.6.0 release. HOT 2
- Would pull requests with typescript *.d.ts definition files be welcome HOT 1
- Overlapping Voronoi polygons HOT 6
- geo_hull() Use more semantically meaningful Set and Map. HOT 2
- geo_edges: Use the more semantically meaningful Set HOT 3
- Benchmarks: A uniform approach HOT 1
- Extend and correct benchmarking HOT 2
- Add code coverage
- Export base functions to compute elements as they are needed HOT 4
- Error in hull HOT 3
- Inconsistent broken projection of a 4 - segment beach ball HOT 3
- Voronoi where each site is a segment instead of a point.
- Bounding box support for geoVoronoi HOT 4
- Unexpected Singularities in Projection HOT 7
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-voronoi.