Giter Site home page Giter Site logo

Comments (6)

Fil avatar Fil commented on May 23, 2024 2

The technique works with the current releases (d3-geo@1, d3-geo-projection@2 and d3-geo-polygon@1). The relevant call is

projection.preclip(d3.geoClipPolygon(ellipse));

where ellipse is a GeoJSON polygon that goes β€œaround” the antipodes of the two centers a and b (in the rotation that puts them symmetrically around [0,0] on the equator):

const eps = 1e-3, u = (d3.geoDistance(a, b) / 2) * degrees + eps,
  ellipse = {
    type: "Polygon",
    coordinates: [[
        [180 - u, eps],
        [180 - u, -eps],
        [-180 + u, -eps],
        [-180 + u, eps],
        [180 - u, eps]
      ]]
  };

from d3-geo-projection.

Fil avatar Fil commented on May 23, 2024 1

I have updated https://observablehq.com/@fil/two-point-equidistant with polygon clipping. The polygon in question is quite simple: it's just a rectangle that runs around the antipodes of the two centers. It covers 99.9996% of the globe ;)

two-point-equidistant

from d3-geo-projection.

Fil avatar Fil commented on May 23, 2024

Not an answer to your question, but here's a modernized version, with a clip-angle of 145Β°:
https://observablehq.com/@fil/two-point-equidistant

from d3-geo-projection.

Fil avatar Fil commented on May 23, 2024

Oh and, if you want spherical ellipses, we got it covered too:
https://observablehq.com/@fil/spherical-ellipses

(turns out they're not needed for this projection since we want the "largest" ellipse we can get, and that's our simple polygon).

from d3-geo-projection.

beuan avatar beuan commented on May 23, 2024

Cool! I will have to wait for the next release, but how can I add this clipping polygon to my call?

return d3.geoTwoPointEquidistant([lon1, lat1],[lon2, lat2])
         .clipAngle(105);

Thanks! πŸ™πŸ»

from d3-geo-projection.

beuan avatar beuan commented on May 23, 2024

Sweet! It works like a charm. Thank you for your help, @Fil! πŸ™πŸ»

from d3-geo-projection.

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.