summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2017-06-28 14:36:28 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2017-06-28 20:59:56 +0300
commit1df45a5e42b8f299d01cea09c9717c5df287f0b7 (patch)
tree50e507df58a0caa32de0636871d1e1c750de112c
parent433e54e636293eb3b6644c143866aa0d39198441 (diff)
downloadqtlocation-mapboxgl-1df45a5e42b8f299d01cea09c9717c5df287f0b7.tar.gz
[core] Check if frameZoom is NaN in Transform::flyTo callback
-rw-r--r--src/mbgl/map/transform.cpp5
-rw-r--r--test/map/transform.test.cpp5
2 files changed, 10 insertions, 0 deletions
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp
index 8d05bc0e91..50f979437d 100644
--- a/src/mbgl/map/transform.cpp
+++ b/src/mbgl/map/transform.cpp
@@ -293,6 +293,11 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
Point<double> framePoint = util::interpolate(startPoint, endPoint, us);
double frameZoom = startZoom + state.scaleZoom(1 / w(s));
+ // Zoom can be NaN if size is empty.
+ if (std::isnan(frameZoom)) {
+ frameZoom = zoom;
+ }
+
// Convert to geographic coordinates and set the new viewpoint.
LatLng frameLatLng = Projection::unproject(framePoint, startScale);
state.setLatLngZoom(frameLatLng, frameZoom);
diff --git a/test/map/transform.test.cpp b/test/map/transform.test.cpp
index 6d41a868dc..11c2c1cc6b 100644
--- a/test/map/transform.test.cpp
+++ b/test/map/transform.test.cpp
@@ -36,6 +36,11 @@ TEST(Transform, InvalidZoom) {
cameraOptions.center = LatLng { util::LATITUDE_MAX, util::LONGITUDE_MAX };
cameraOptions.zoom = transform.getState().getMaxZoom();
+ // Executing flyTo with an empty size causes frameZoom to be NaN.
+ transform.flyTo(cameraOptions);
+ transform.updateTransitions(transform.getTransitionStart() + transform.getTransitionDuration());
+ ASSERT_DOUBLE_EQ(transform.getZoom(), transform.getState().getMaxZoom());
+
// Executing flyTo with maximum zoom level to the same zoom level causes
// frameZoom to be bigger than maximum zoom.
transform.resize(Size { 100, 100 });