Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use clipPolygon for geoInterrupted #17

Closed
Fil opened this issue Apr 19, 2018 · 2 comments · Fixed by #65
Closed

Use clipPolygon for geoInterrupted #17

Fil opened this issue Apr 19, 2018 · 2 comments · Fixed by #65
Assignees

Comments

@Fil
Copy link
Member

Fil commented Apr 19, 2018

example code that works (at least in one test case):

var c = projection.lobes().map(d => d3.merge(d.map(q => {
  var centroid = d3.geoCentroid({type:"MultiPoint", coordinates:q});
  return q.map(p => d3.geoInterpolate(p,centroid)(1e-7)); // pull inside each lobe
})));
c = d3.merge([c[0], c[1].reverse()]); // north, south
projection.preclip(d3.geoClipPolygon({ type: "Polygon", coordinates: [c] }));

capture d ecran 2018-04-19 a 09 31 17

the projection was defined by:

    var lobes = [
      [
        [[-180, 0], [-130, 90], [-95, 0]],
        [[-95, 0], [-30, 90], [55, 0]],
        [[55, 0], [120, 90], [180, 0]]
      ],
      [
        [[-180, 0], [-120, -90], [-60, 0]],
        [[-60, 0], [20, -90], [85, 0]],
        [[85, 0], [140, -90], [180, 0]]
      ]
    ];
    projection = d3.geoInterrupt(d3.geoHomolosineRaw, lobes).rotate([-204, 0])
    .fitExtent([[10, 10], [width-10, height-10]], {type: "Sphere"});
@Fil Fil self-assigned this Apr 19, 2018
@Fil Fil mentioned this issue Sep 9, 2018
@Fil
Copy link
Member Author

Fil commented Sep 9, 2018

Solved in https://observablehq.com/@fil/interrupted-projections-polygon-clipping for all "interrupted" projections of d3-geo-projection, including HEALPix.

@Fil
Copy link
Member Author

Fil commented Sep 9, 2018

Have to think about how to integrate this — I'd rather not duplicate all the code from geo-projection, but for users I want it to be as simple as adding d3-geo-polygon to their sources (like we have for the polyhedral projections).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant