-
Notifications
You must be signed in to change notification settings - Fork 161
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.copy? #123
Comments
+1 for immutable projections. I might even be able to help with this |
Should we try and do this for d3-geo@2 d3-geo-projection@3 d3-geo-polygon@2 ? I'm really not sure about immutable projections — they would mean rewriting almost all map interactions everywhere; but projection.copy() would be super useful in many instances. Related (maybe), I very often find that I would need the projections to carry some metadata (for example & at the very least, a name; but also a flag indicating if it needs clipping to the sphere, etc). |
This would come in very handy when implementing rotation calculations as I currently need to set the rotation to For example: function getProjectedPoint(projection, event) {
const originalRotation = projection.rotate()
const pt = pointers(event, event.sourceEvent.target)[0]
const result = projection.rotate([0, 0]).invert(pt)
projection.rotate(originalRotation)
return result
} |
Agree, but I don't have the beginning of an idea how to implement this—projections are a very complex object and there's no easy "deep clone" operation. Maybe I'm missing something? Contributions are welcome. |
It’d be nice to have a method to create a copy of a projection with identical settings (that, or change projections to be immutable, and every method that modifies the projection instead returns a new projection).
The text was updated successfully, but these errors were encountered: