diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-05-12 12:38:12 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-05-17 13:20:25 -0700 |
commit | 7e5d0ff49e2b5a6a3caa45464d8056e93431d780 (patch) | |
tree | 665519111b6877ccab34d02831dc66d09b4e75ac /src/mbgl/map/transform.cpp | |
parent | 3e21e3887aa08ea32e4370b8c6e990d9f8c4333f (diff) | |
download | qtlocation-mapboxgl-7e5d0ff49e2b5a6a3caa45464d8056e93431d780.tar.gz |
[core] Rewrite TileCoordinate in terms of geometry.hpp point
Diffstat (limited to 'src/mbgl/map/transform.cpp')
-rw-r--r-- | src/mbgl/map/transform.cpp | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index 958f9d9b63..4a40e13202 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -109,14 +109,9 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim // Find the shortest path otherwise. else startLatLng.unwrapForShortestPath(latLng); - const ScreenCoordinate startPoint = { - state.lngX(startLatLng.longitude), - state.latY(startLatLng.latitude), - }; - const ScreenCoordinate endPoint = { - state.lngX(latLng.longitude), - state.latY(latLng.latitude), - }; + const Point<double> startPoint = state.project(startLatLng); + const Point<double> endPoint = state.project(latLng); + ScreenCoordinate center = getScreenCoordinate(padding); center.y = state.height - center.y; @@ -145,11 +140,8 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim state.rotating = angle != startAngle; startTransition(camera, animation, [=](double t) { - ScreenCoordinate framePoint = util::interpolate(startPoint, endPoint, t); - LatLng frameLatLng = { - state.yLat(framePoint.y, startWorldSize), - state.xLng(framePoint.x, startWorldSize) - }; + Point<double> framePoint = util::interpolate(startPoint, endPoint, t); + LatLng frameLatLng = state.unproject(framePoint, startWorldSize); double frameScale = util::interpolate(startScale, scale, t); state.setLatLngZoom(frameLatLng, state.scaleZoom(frameScale)); @@ -191,14 +183,9 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima LatLng startLatLng = getLatLng(padding).wrapped(); startLatLng.unwrapForShortestPath(latLng); - const ScreenCoordinate startPoint = { - state.lngX(startLatLng.longitude), - state.latY(startLatLng.latitude), - }; - const ScreenCoordinate endPoint = { - state.lngX(latLng.longitude), - state.latY(latLng.latitude), - }; + const Point<double> startPoint = state.project(startLatLng); + const Point<double> endPoint = state.project(latLng); + ScreenCoordinate center = getScreenCoordinate(padding); center.y = state.height - center.y; @@ -316,14 +303,11 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima double us = u(s); // Calculate the current point and zoom level along the flight path. - ScreenCoordinate framePoint = util::interpolate(startPoint, endPoint, us); + Point<double> framePoint = util::interpolate(startPoint, endPoint, us); double frameZoom = startZoom + state.scaleZoom(1 / w(s)); // Convert to geographic coordinates and set the new viewpoint. - LatLng frameLatLng = { - state.yLat(framePoint.y, startWorldSize), - state.xLng(framePoint.x, startWorldSize), - }; + LatLng frameLatLng = state.unproject(framePoint, startWorldSize); state.setLatLngZoom(frameLatLng, frameZoom); if (angle != startAngle) { |