diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2015-11-10 16:31:42 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2015-11-11 16:59:49 +0200 |
commit | cd0266f25cc96358e665b6f39e358a263f6d4ab8 (patch) | |
tree | 9268e53746f9ff5ed9d1b72ba215ee4e45d104bb | |
parent | 12e0e5eb0434e3243e0dd6fedf8be7e6c5d1cbca (diff) | |
download | qtlocation-mapboxgl-cd0266f25cc96358e665b6f39e358a263f6d4ab8.tar.gz |
[core] Added more NaN checks in Transform
-rw-r--r-- | src/mbgl/map/transform.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index c58e56f31a..cf39f2d32d 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -10,12 +10,17 @@ #include <mbgl/platform/platform.hpp> #include <cstdio> +#include <cmath> using namespace mbgl; /** Converts the given angle (in radians) to be numerically close to the anchor angle, allowing it to be interpolated properly without sudden jumps. */ static double _normalizeAngle(double angle, double anchorAngle) { + if (std::isnan(angle) || std::isnan(anchorAngle)) { + return 0; + } + angle = util::wrap(angle, -M_PI, M_PI); if (angle == -M_PI) angle = M_PI; double diff = std::abs(angle - anchorAngle); @@ -66,7 +71,7 @@ void Transform::easeTo(const CameraOptions& options) { LatLng latLng = easeOptions.center ? *easeOptions.center : getLatLng(); double zoom = easeOptions.zoom ? *easeOptions.zoom : getZoom(); double angle = easeOptions.angle ? *easeOptions.angle : getAngle(); - if (!latLng.isValid() || std::isnan(zoom)) { + if (!latLng.isValid() || std::isnan(zoom) || std::isnan(angle)) { return; } @@ -139,7 +144,11 @@ void Transform::setLatLng(const LatLng& latLng, const PrecisionPoint& point, con setLatLng(newLatLng, duration); } -void Transform::setLatLngZoom(const LatLng& latLng, const double zoom, const Duration& duration) { +void Transform::setLatLngZoom(const LatLng& latLng, double zoom, const Duration& duration) { + if (!latLng.isValid() || std::isnan(zoom)) { + return; + } + CameraOptions options; options.center = latLng; options.zoom = zoom; @@ -366,6 +375,10 @@ double Transform::getAngle() const { #pragma mark - Pitch void Transform::setPitch(double pitch, const Duration& duration) { + if (std::isnan(pitch)) { + return; + } + CameraOptions options; options.pitch = pitch; options.duration = duration; |