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

geoTransverseProjection? #157

Open
mbostock opened this issue Mar 10, 2019 · 5 comments
Open

geoTransverseProjection? #157

mbostock opened this issue Mar 10, 2019 · 5 comments

Comments

@mbostock
Copy link
Member

It’s pretty easy to do generically:

projection = d3.geoProjection((x, y) => d3.geoEquirectangularRaw(-x, y).reverse()).rotate([0, 0, 90])
@Fil
Copy link
Member

Fil commented May 12, 2019

@Fil
Copy link
Member

Fil commented May 13, 2019

A much simpler solution:

d3.geoEquirectangular()
  .rotate([0, 0, 90])
  .angle(-90)

Should we add it to https://github.com/d3/d3-geo/blob/master/README.md#projection_angle ?

@mbostock
Copy link
Member Author

That worked for Atlantis, too:

https://observablehq.com/@d3/atlantis

Maybe it was just Mercator that needed this more elaborate solution because of its automatic clipping behavior.

@Fil
Copy link
Member

Fil commented May 13, 2019

Yes, I guess it should be requalified as a bug of projection.angle

@Fil
Copy link
Member

Fil commented Sep 18, 2019

The issue seems to lie in clipAntimeridianInterpolate which takes large strides along the antimeridian line. This doesn't work well later with clipExtent.

A way to fix it is to take smaller steps; but as it adds intermediate points, it breaks about a dozen unit tests which expect an exact path, and makes a heavier SVG path.

--- a/src/clip/antimeridian.js
+++ b/src/clip/antimeridian.js
@@ -68,17 +68,21 @@ function clipAntimeridianIntersect(lambda0, phi0, lambda1, phi1) {
 }

 function clipAntimeridianInterpolate(from, to, direction, stream) {
-  var phi;
+  var phi, e;
   if (from == null) {
     phi = direction * halfPi;
     stream.point(-pi, phi);
-    stream.point(0, phi);
+    for (e = -pi; e < pi; e+=0.01)
+      stream.point(e, phi);
     stream.point(pi, phi);
-    stream.point(pi, 0);
+    for (e = -halfPi; e < halfPi; e+= 0.01)
+      stream.point(pi, -direction * e);
     stream.point(pi, -phi);
-    stream.point(0, -phi);
+    for (e = -pi; e < pi; e += 0.01)
+      stream.point(-e, -phi);
     stream.point(-pi, -phi);
-    stream.point(-pi, 0);
+    for (e = -halfPi; e < halfPi; e+= 0.01)
+      stream.point(-pi, direction * e);
     stream.point(-pi, phi);
   } else if (abs(from[0] - to[0]) > epsilon) {
     var lambda = from[0] < to[0] ? pi : -pi;

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

No branches or pull requests

2 participants