summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2018-07-07 00:31:02 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2018-07-09 22:02:49 +0300
commit68bed94cd1492e49e2aa191a293ead54b80ac918 (patch)
tree5f78f66c03e0c6e230aad35a56ac5a7a99805c32 /include
parent37e680c66b99b28d9fae9e15a1690a94760cb3a9 (diff)
downloadqtlocation-mapboxgl-68bed94cd1492e49e2aa191a293ead54b80ac918.tar.gz
[core] Harden Projection::project()
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/util/projection.hpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/mbgl/util/projection.hpp b/include/mbgl/util/projection.hpp
index 65a84d8dc2..9619a380b4 100644
--- a/include/mbgl/util/projection.hpp
+++ b/include/mbgl/util/projection.hpp
@@ -94,9 +94,10 @@ public:
private:
static Point<double> project_(const LatLng& latLng, double worldSize) {
+ const double latitude = util::clamp(latLng.latitude(), -util::LATITUDE_MAX, util::LATITUDE_MAX);
return Point<double> {
util::LONGITUDE_MAX + latLng.longitude(),
- util::LONGITUDE_MAX - util::RAD2DEG * std::log(std::tan(M_PI / 4 + latLng.latitude() * M_PI / util::DEGREES_MAX))
+ util::LONGITUDE_MAX - util::RAD2DEG * std::log(std::tan(M_PI / 4 + latitude * M_PI / util::DEGREES_MAX))
} * worldSize / util::DEGREES_MAX;
}
};