d3 / d3-geo-projection

Extended geographic projections for d3-geo.
https://observablehq.com/collection/@d3/d3-geo-projection
Other
1.11k stars 201 forks source link

compatibility of geoRectangularPolyconicRaw with geoInterrupt #178

Open mxfh opened 5 years ago

mxfh commented 5 years ago

passing geoRectangularPolyconicRaw with no phi0 to geoInterrupt returns only NaNs and with phi0 > 0 the lobes are becoming increasingly offset away from the center. see behavior here. Is this expected or should that be compensated and defaulted in the case of unset phi0? https://observablehq.com/@mxfh/compatibility-of-georectangularpolyconicraw-with-geoin

Fil commented 5 years ago

geoRectangularPolyconicRaw with no phi0 returns NaNs because geoRectangularPolyconicRaw is a function (of phi0) that returns a raw projection. So that's expected.

The second part of your comment seems indeed to point to something missing in the way we compute the shifting of the lobes, by assuming that the equator is of constant scale (if I'm reading correctly https://github.com/d3/d3-geo-projection/blob/master/src/interrupted/index.js#L74 )

(As phi0 is the "true scale" parallel of that projection (expressed in radians), when you set it to 0 you effectively get a true scale equator which explains why the lobes are correctly contiguous in this case.)

mxfh commented 5 years ago

I see that the lobe origin is scaled at the non-true scale for non-zero phi0, but most curious about why it seems to not effect lobe count = 2 ? Because the scaled lobe offset is cancelled out by the scale change within the lobe at equator?

This seems to affect all projections where the raw function is a function of a parallel/parallels or with a non-true scaled equator.

See Armadillo here: compatibility-of-georectangularpolyconicraw-with-geoin

Fil commented 5 years ago

I just commited a change that addresses the issue. It's not complete (no inverse, no tests…), but it's a start :)

You can test the build at https://observablehq.com/d/bde6f23d798d4f72 (it uses https://files-6p35z2y9v.now.sh/d3-geo-projection.js )

I've also removed the meaningless geoRectangularPolyconicRaw test.

See branch https://github.com/d3/d3-geo-projection/tree/issue178