Skip to content

Transverse Mercator #55

mbostock opened this Issue Mar 10, 2013 · 5 comments

2 participants

D3 member

It would be nice to have a transverse Mercator projection with the 90° rotation built-in. That way, you can easily use a transverse Mercator without needing to also apply a 90° rotation to the rendered result. Should be a pretty simple transformation of d3.geo.mercator.raw.

@jasondavies jasondavies added a commit that closed this issue Mar 11, 2013
@jasondavies jasondavies Add d3.geo.transverseMercator.
Fixes #55.
D3 member

Nice, thank you for implementing this!

I see you chose not to preserve the 2π scale multiple of the existing d3.geo.mercator. I think it's probably a good idea to not have this scale factor, as it makes it easier to use D3's mercator with GDAL (since the scale factor becomes the radius of the Earth), and it's the minimal essence of the projection. On the other hand, I think it's also important that mercator and transverseMercator function consistently.

Ideally, we would remove the 2π scale factor from the d3.geo.mercator. However, this would break most existing code that uses d3.geo.mercator (even if it doesn't throw an error), and so this should be considered backwards-incompatible reserved for 4.0. But, we could throw caution to the wind and call it a "bug fix"…

Or, we could create a new d3.geo.sphericalMercator projection without the 2π, and deprecate d3.geo.mercator. But then in 4.0, would we deprecate the sphericalMercator alias after removing the 2π scale factor? And then in 5.0 remove sphericalMercator? That's clunky, and verbose. And also, this might be confusing since it suggests that d3.geo.mercator is not spherical, when in practice we'd control that through some other property of the d3.geo.projection. Other names might be "mercator2", "fixedMercator", "unscaledMercator"…

Or, we could fix only d3.geo.mercator.raw, and make d3.geo.mercator's scale function backwards-compatible by multiplying by 2π internally. This would allow you to create your own non-scaled projection as d3.geo.projection(d3.geo.mercator.raw), while d3.geo.mercator would behave the same as it always has. This isn't a horrible solution, but it doesn't really make d3.geo.mercator consistent with d3.geo.transverseMercator, and it doesn't provide a path to deprecation for the old scale factor. So, it doesn't really accomplish anything except add junk code! :)

Do you have a preference? I guess I'm leaning towards removing the scale factor from d3.geo.mercator, and then fixing the affected examples (such as the d3.geo.tile demo).

D3 member

I’d prefer to remove the scale factor from d3.geo.mercator and fix all affected examples. I think we can make a special exception here as it’s not exactly difficult for people to add the factor back in if they are relying on it at the moment. :)

This will also be consistent with d3.geo.conicConformal(0, 0), for which I’ve included an unscaled raw mercator in the plugin.

D3 member

I just noticed that. OK, let's do it.

I'm also tempted to add transverseMercator, conicConformal and conicEquidistant to core. And add conicEqualArea as an alias for Albers, but without the U.S.-centric default settings.

D3 member

Sounds good! Adding the other conics would cover the vast majority of common projections used, and of course Transverse Mercator is very widely used e.g. for UTM.

BTW, I’m thinking of adding ellipsoidal formulations for slightly better accuracy for all of the above, but I can always develop that in the plugin to start with.

D3 member

OK, filed mbostock/d3#1133 to track. Looking forward to the elliptical formulations, too. A plugin sounds like the right place to start there!

(Also related: still thinking about how best to do static bundling for D3, so that it's easy to compile-in only the needed features.)

@mbostock mbostock added a commit to mbostock/d3 that referenced this issue Mar 11, 2013
@mbostock mbostock Add transverseMercator; remove custom scales.
This adds d3.geo.transverseMercator and removes the custom default scales from
the mercator and equirectangular projections. Also, this commit removes the
built-in 2π scale factor from the mercator projection, simplifying the
implementation and making it consistent with transverseMercator and GDAL. This
is a partial fix for #1133; see also d3/d3-plugins#55.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.