Conversation
mbostock
left a comment
There was a problem hiding this comment.
Okay, I have pared back this PR by avoiding the introduction of a new “materialized projection” interface (i.e., Projection), instead exposing the existing ProjectionImplementation interface which was already exposed as context.projection.
This avoids the challenge of trying to normalize a provided ProjectionImplementation into a Projection (noted above). More importantly, it ensures when you reuse a projection across a plot, the projections behave identically rather than rescaling the projection to fit the dimensions of the other plot. This mirrors the current behavior of plot.scale (with respect to scales), and I believe is what we want. If you want to share the same projection type (or some other partial specification of a projection), then you should simply splat your projection options into multiple plots; you don’t need plot.scale to help with that.
All that said, I’d still like to expose a projection.apply and projection.invert convenience method, since that seems useful for implementing interaction. And in the case that the provided projection implementation is a function and exposes projection.invert, we can simply use that as-is. I’ll work on that next…
d26e559 to
08ef2dd
Compare
plot.scale("projection")exposes the materialized projection from a plotThe returned object exposes the resolved projection options, reflecting the actual values used to construct the projection, making it possible to create a new plot with the same projection. The projection object also exposes an apply method that projects a [longitude, latitude] point to [x, y] pixel coordinates, as well as an invert method.
closes #1191
supersedes #2038