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

Projection naturalEarth supports pacific view or other projection center #12010

Closed
zxj5470 opened this issue Jun 17, 2022 · 1 comment
Closed

Comments

@zxj5470
Copy link

zxj5470 commented Jun 17, 2022

Motivation

I found that the projection naturalEarth uses the code by d3-geo. But current view is only centered by [0, 0] .

And d3 has other center view like pacific by using .rotate([200, 0]), by offset
(This API named rotate is an Ambiguous name, and 200 means -160 means 160°E,wtf)

The features what I want is add an API named like offset in natural_earth.js to set longitude 160°E as center when changing projection.

map.setProjection({
  name: "naturalEarth", 
  offset: [160, 0], //  pacific as center
})

Design Alternatives

Design

https://observablehq.com/@d3/natural-earth
image

Mock-Up

map.setProjection({
  name: "naturalEarth", 
  offset: [160, 0], //  pacific as center
})

Concepts

Implementation

d3-geo code:
https://github.com/d3/d3-geo/blob/0c27527d4f9f500698b28d33289ee1104ee22990/src/projection/index.js#L157-L165

// code usage
projection = d3.geoNaturalEarth1().rotate([200, 0])


  projection.rotate = function(_) {
    return arguments.length ? (deltaLambda = _[0] % 360 * radians, 
deltaPhi = _[1] % 360 * radians, 
deltaGamma = _.length > 2 ? _[2] % 360 * radians : 0, 
recenter()) : [deltaLambda * degrees, deltaPhi * degrees, deltaGamma * degrees];
  };

  function recenter() {
    var center = scaleTranslateRotate(k, 0, 0, sx, sy, alpha).apply(null, project(lambda, phi)),
        transform = scaleTranslateRotate(k, x - center[0], y - center[1], sx, sy, alpha);
    rotate = rotateRadians(deltaLambda, deltaPhi, deltaGamma);
    projectTransform = compose(project, transform);
    projectRotateTransform = compose(rotate, projectTransform);
    projectResample = resample(projectTransform, delta2);
    return reset();
  }
@mourner
Copy link
Member

mourner commented Jun 17, 2022

Yeah, we would like to implement this eventually, although it's not trivial for GL JS. Closing as duplicate of #11180

@mourner mourner closed this as not planned Won't fix, can't repro, duplicate, stale Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants