Giter Club home page Giter Club logo

Comments (9)

Fil avatar Fil commented on May 14, 2024

Excellent remark. Would you mind sending a PR?

from d3-geo-voronoi.

nunojpg avatar nunojpg commented on May 14, 2024

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.

nunojpg avatar nunojpg commented on May 14, 2024

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.

nunojpg avatar nunojpg commented on May 14, 2024

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.

nunojpg avatar nunojpg commented on May 14, 2024

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.

Fil avatar Fil commented on May 14, 2024

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.

nunojpg avatar nunojpg commented on May 14, 2024

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.

Fil avatar Fil commented on May 14, 2024

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.

nunojpg avatar nunojpg commented on May 14, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.