From b1ed80775dc729818326f63aaa0442b7bed8261c Mon Sep 17 00:00:00 2001 From: tobrun Date: Thu, 7 Feb 2019 15:36:21 +0100 Subject: [core] - add optional limit maximum degrees --- include/mbgl/util/geo.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/mbgl/util/geo.hpp b/include/mbgl/util/geo.hpp index 033114f8c2..6e626d6d8a 100644 --- a/include/mbgl/util/geo.hpp +++ b/include/mbgl/util/geo.hpp @@ -59,9 +59,9 @@ public: // If the distance from start to end longitudes is between half and full // world, unwrap the start longitude to ensure the shortest path is taken. - void unwrapForShortestPath(const LatLng& end) { + void unwrapForShortestPath(const LatLng& end, bool limitMaxDegrees = true) { const double delta = std::abs(end.lon - lon); - if (delta <= util::LONGITUDE_MAX) return; + if (delta <= util::LONGITUDE_MAX || (limitMaxDegrees && delta >= util::DEGREES_MAX)) return; if (lon > 0 && end.lon < 0) lon -= util::DEGREES_MAX; else if (lon < 0 && end.lon > 0) lon += util::DEGREES_MAX; } @@ -133,7 +133,7 @@ public: } LatLng latLng = p; if (crossesAntimeridian()) { - latLng.unwrapForShortestPath(ne); + latLng.unwrapForShortestPath(ne, false); } return LatLng { util::clamp(latLng.latitude(), sw.latitude(), ne.latitude()), -- cgit v1.2.1