summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnsis Brammanis <brammanis@gmail.com>2017-06-06 15:43:39 -0400
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-06-06 13:22:02 -0700
commit0c77ce7b5f06bf7002f4d845456aa15d2428d473 (patch)
tree91939b459cf0e0e3f9cce590e8a70bb9fde44b1d
parentdb7bb509e95d737199efa73a47bdcc973966ed97 (diff)
downloadqtlocation-mapboxgl-upstream/release-ios-v3.5.0-android-v5.0.0.tar.gz
fix #8300 flyTo for close pointsupstream/release-ios-v3.5.0-android-v5.0.0
The isClose threshold is switched from 0.000001 pixels to 1 pixel. As a backup, it checks whether r0 and r1 are finite. It might be possible to have just the threshold check or just the finiteness check, but I don't see the harm in having both. std::abs(w0 - w1) < 0.000001 is removed because it doesn't look like it's needed. All calculations should run fine even if w0 === w1. Finally, the point interpolation is tweaked so that at the end of the flying (when k === 1) it ends up at the exact end point. I didn't see any bugs related to this, but it seems like a good thing to have explicitly.
-rw-r--r--src/mbgl/map/transform.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp
index 42fc50f899..1aa0d87fc9 100644
--- a/src/mbgl/map/transform.cpp
+++ b/src/mbgl/map/transform.cpp
@@ -241,16 +241,13 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
return std::log(std::sqrt(b * b + 1) - b);
};
- // When u₀ = u₁, the optimal path doesn’t require both ascent and descent.
- bool isClose = std::abs(u1) < 0.000001;
- // Perform a more or less instantaneous transition if the path is too short.
- if (isClose && std::abs(w0 - w1) < 0.000001) {
- easeTo(camera, animation);
- return;
- }
-
/// r₀: Zoom-out factor during ascent.
double r0 = r(0);
+ double r1 = r(1);
+
+ // When u₀ = u₁, the optimal path doesn’t require both ascent and descent.
+ bool isClose = std::abs(u1) < 1.0 || !std::isfinite(r0) || !std::isfinite(r1);
+
/** w(s): Returns the visible span on the ground, measured in pixels with
respect to the initial scale.
@@ -268,7 +265,7 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
};
/// S: Total length of the flight path, measured in ρ-screenfuls.
double S = (isClose ? (std::abs(std::log(w1 / w0)) / rho)
- : ((r(1) - r0) / rho));
+ : ((r1 - r0) / rho));
Duration duration;
if (animation.duration) {
@@ -296,7 +293,7 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
/// s: The distance traveled along the flight path, measured in
/// ρ-screenfuls.
double s = k * S;
- double us = u(s);
+ double us = k == 1.0 ? 1.0 : u(s);
// Calculate the current point and zoom level along the flight path.
Point<double> framePoint = util::interpolate(startPoint, endPoint, us);