diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-03-07 18:07:23 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-03-10 03:36:45 +0200 |
commit | 026b6d4c01a3d96af9629cc1790373137ecab950 (patch) | |
tree | c63cdb8429c793c3abfa8bc92c68c8fb848d7c54 /src/mbgl/map/transform.cpp | |
parent | 808bf7004a4360a4cc7095f97c235c92d3679f8b (diff) | |
download | qtlocation-mapboxgl-026b6d4c01a3d96af9629cc1790373137ecab950.tar.gz |
[core] Coordinate wrapping fixes
- Make returning LatLngs unwrapped by default.
- PointAnnotation and ShapeAnnotation are always wrapped so they can be
selected via intersection from the visible tile boundaries.
- Fixes LatLng::wrap() calculation.
- Fixes LatLng::unwrapForShortestPath() calculation.
The new unwrapForShortestPath algorithm unwraps the start coordinate
either forwards or backwards depending on the end coordinate value, so
we can always cross the antimeridian when needed and still obtain a
wrapped end coordinate in the end.
Fixes #4214.
Diffstat (limited to 'src/mbgl/map/transform.cpp')
-rw-r--r-- | src/mbgl/map/transform.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index 74e43a62fe..79b43f8901 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -95,12 +95,17 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim if (camera.padding) { padding = *camera.padding; } - const LatLng startLatLng = getLatLng(padding); + + LatLng startLatLng = getLatLng(padding); + startLatLng.unwrapForShortestPath(latLng); + + // Make sure the end coordinate always remains valid. + latLng.wrap(); + const ScreenCoordinate startPoint = { state.lngX(startLatLng.longitude), state.latY(startLatLng.latitude), }; - latLng.unwrapForShortestPath(getLatLng()); const ScreenCoordinate endPoint = { state.lngX(latLng.longitude), state.latY(latLng.latitude), @@ -136,7 +141,7 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim ScreenCoordinate framePoint = util::interpolate(startPoint, endPoint, t); LatLng frameLatLng = { state.yLat(framePoint.y, startWorldSize), - state.xLng(framePoint.x, startWorldSize), + state.xLng(framePoint.x, startWorldSize) }; double frameScale = util::interpolate(startScale, scale, t); state.setLatLngZoom(frameLatLng, state.scaleZoom(frameScale)); @@ -178,12 +183,17 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima if (camera.padding) { padding = *camera.padding; } - const LatLng startLatLng = getLatLng(padding); + + LatLng startLatLng = getLatLng(padding); + startLatLng.unwrapForShortestPath(latLng); + + // Make sure the end coordinate always remains valid. + latLng.wrap(); + const ScreenCoordinate startPoint = { state.lngX(startLatLng.longitude), state.latY(startLatLng.latitude), }; - latLng.unwrapForShortestPath(getLatLng()); const ScreenCoordinate endPoint = { state.lngX(latLng.longitude), state.latY(latLng.latitude), |