Fix geo projections losing their D3 default rotation - #7976
Open
CAOShurong wants to merge 2 commits into
Open
Conversation
Geo.updateProjection unconditionally called projection.rotate([-rotation.lon, -rotation.lat, rotation.roll]), so the default projection.rotation attributes ([0, 0, 0]) discarded the rotation the d3 projection factory ships with. Six projections are affected (albers, bertin1953, gringorten and peirce quincuncial, sinu mollweide, wiechel). Capture the factory rotation when the projection wrapper is created and compose the user rotation on top of it. Projections whose d3 default is the identity are bit-for-bit unchanged; an explicit rotation now rotates relative to the projection's canonical orientation instead of replacing it. Fixes plotly#7949
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Geo.updateProjectionsetsprojection.rotate([-rotation.lon, -rotation.lat, rotation.roll])unconditionally. Sinceprojection.rotationdefaults to[0, 0, 0], the rotation the d3 projection factory ships with is discarded for the six projections that carry a non-identity default (albers[96, 0, 0], bertin1953, gringorten and peirce quincuncial[-90, -90, 45], sinu mollweide, wiechel) — #7949.Fix
Capture the factory rotation when the projection wrapper is created (
projection.defaultRotation) and compose the user rotation on top of it:projection.rotation, the six affected projections now keep their canonical orientation (the reported bug);projection.rotationas additional rotation on top of the projection's own orientation, and are what makes both defaults and explicit values consistent without tracking whether each attribute was user-set.Test
Adds a regression spec asserting
alberskeeps[96, 0, 0]at defaults, composes (96 - 10) whenrotation.lon: 10is set, and thatmercatorstays exactly[0, 0, 0].Fixes #7949