diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-03-10 19:49:09 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-03-18 00:53:14 +0200 |
commit | ac70ada2d3e9b842a1fd3f46361d323ddb20d232 (patch) | |
tree | d1dedaf12bee23241b55622210378981299a567c /src | |
parent | cfcccb94a10c60444438049c078b066ea9a08463 (diff) | |
download | qtlocation-mapboxgl-ac70ada2d3e9b842a1fd3f46361d323ddb20d232.tar.gz |
[core] Check for NaNs in mbgl::util::{min,max,clamp}
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/annotation/shape_annotation_impl.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/map/transform.cpp | 1 | ||||
-rw-r--r-- | src/mbgl/util/geo.cpp | 5 |
3 files changed, 7 insertions, 4 deletions
diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp index a9277ee0a7..9adebf177b 100644 --- a/src/mbgl/annotation/shape_annotation_impl.cpp +++ b/src/mbgl/annotation/shape_annotation_impl.cpp @@ -4,6 +4,7 @@ #include <mbgl/annotation/annotation_manager.hpp> #include <mbgl/annotation/annotation_tile.hpp> #include <mbgl/util/constants.hpp> +#include <mbgl/util/math.hpp> #include <mbgl/util/string.hpp> #include <mbgl/style/style.hpp> #include <mbgl/layer/line_layer.hpp> @@ -90,8 +91,8 @@ void ShapeAnnotationImpl::updateTile(const TileID& tileID, AnnotationTile& tile) std::vector<geojsonvt::LonLat> points; for (size_t i = 0; i < shape.segments[0].size(); ++i) { // first segment for now (no holes) - const double constraintedLatitude = ::fmin(::fmax(shape.segments[0][i].latitude, -util::LATITUDE_MAX), util::LATITUDE_MAX); - points.push_back(geojsonvt::LonLat(shape.segments[0][i].longitude, constraintedLatitude)); + const double constrainedLatitude = util::clamp(shape.segments[0][i].latitude, -util::LATITUDE_MAX, util::LATITUDE_MAX); + points.push_back(geojsonvt::LonLat(shape.segments[0][i].longitude, constrainedLatitude)); } if (type == geojsonvt::ProjectedFeatureType::Polygon && diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index da085ac750..0c9f7bf1e6 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -410,6 +410,7 @@ void Transform::scaleBy(double ds, const Duration& duration) { } void Transform::scaleBy(double ds, optional<ScreenCoordinate> anchor, const Duration& duration) { + if (std::isnan(ds)) return; double scale = util::clamp(state.scale * ds, state.min_scale, state.max_scale); setScale(scale, anchor, duration); } diff --git a/src/mbgl/util/geo.cpp b/src/mbgl/util/geo.cpp index bf7cf38117..7d9db65c4c 100644 --- a/src/mbgl/util/geo.cpp +++ b/src/mbgl/util/geo.cpp @@ -1,3 +1,4 @@ +#include <mbgl/util/math.hpp> #include <mbgl/util/geo.hpp> #include <mbgl/util/constants.hpp> #include <mbgl/map/tile_id.hpp> @@ -13,8 +14,8 @@ LatLng::LatLng(const TileID& id) { } ScreenCoordinate LatLng::project() const { - // Clamp to the latitude limits of Mercator. - const double constrainedLatitude = ::fmin(::fmax(latitude, -util::LATITUDE_MAX), util::LATITUDE_MAX); + // Clamp to the latitude limits of Web Mercator. + const double constrainedLatitude = util::clamp(latitude, -util::LATITUDE_MAX, util::LATITUDE_MAX); // Project a coordinate into unit space in a square map. const double sine = std::sin(constrainedLatitude * util::DEG2RAD); |