diff --git a/benchmark/fixtures/api/cache.db b/benchmark/fixtures/api/cache.db index 64cd376892b..5978c1659d0 100644 Binary files a/benchmark/fixtures/api/cache.db and b/benchmark/fixtures/api/cache.db differ diff --git a/include/mbgl/util/geo.hpp b/include/mbgl/util/geo.hpp index 170eca4f0a9..9e1ecfff91b 100644 --- a/include/mbgl/util/geo.hpp +++ b/include/mbgl/util/geo.hpp @@ -105,14 +105,12 @@ class LatLngBounds { return bounds; } - /// Returns an infinite bound, a bound for which the constrain method returns its + /// Construct an infinite bound, a bound for which the constrain method returns its /// input unmodified. /// /// Note: this is different than LatLngBounds::world() since arbitrary unwrapped /// coordinates are also inside the bounds. - static LatLngBounds unbounded() { - return {}; - } + LatLngBounds() : sw({-90, -180}), ne({90, 180}), bounded(false) {} // Constructs a LatLngBounds object with the tile's exact boundaries. LatLngBounds(const CanonicalTileID&); @@ -172,9 +170,6 @@ class LatLngBounds { LatLngBounds(LatLng sw_, LatLng ne_) : sw(sw_), ne(ne_) {} - LatLngBounds() - : sw({-90, -180}), ne({90, 180}), bounded(false) {} - bool containsLatitude(double latitude) const; bool containsLongitude(double longitude, LatLng::WrapMode wrap) const; diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp index 8cb637fa38f..2b0971599d7 100644 --- a/platform/android/src/native_map_view.cpp +++ b/platform/android/src/native_map_view.cpp @@ -314,7 +314,7 @@ void NativeMapView::setLatLngBounds(jni::JNIEnv& env, const jni::ObjectsetBounds(bounds); } diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index c39b2c904ab..9a2fefaadeb 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -288,11 +288,10 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, break; case GLFW_KEY_D: { static const std::vector bounds = { - mbgl::LatLngBounds::hull(mbgl::LatLng { -45.0, -170.0 }, mbgl::LatLng { 45.0, 170.0 }), // inside - mbgl::LatLngBounds::hull(mbgl::LatLng { -45.0, -200.0 }, mbgl::LatLng { 45.0, -160.0 }), // left IDL - mbgl::LatLngBounds::hull(mbgl::LatLng { -45.0, 160.0 }, mbgl::LatLng { 45.0, 200.0 }), // right IDL - mbgl::LatLngBounds::unbounded() - }; + mbgl::LatLngBounds::hull(mbgl::LatLng{-45.0, -170.0}, mbgl::LatLng{45.0, 170.0}), // inside + mbgl::LatLngBounds::hull(mbgl::LatLng{-45.0, -200.0}, mbgl::LatLng{45.0, -160.0}), // left IDL + mbgl::LatLngBounds::hull(mbgl::LatLng{-45.0, 160.0}, mbgl::LatLng{45.0, 200.0}), // right IDL + mbgl::LatLngBounds()}; static size_t nextBound = 0u; static mbgl::AnnotationID boundAnnotationID = std::numeric_limits::max(); @@ -301,7 +300,7 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, view->map->setBounds(mbgl::BoundOptions().withLatLngBounds(bound)); - if (bound == mbgl::LatLngBounds::unbounded()) { + if (bound == mbgl::LatLngBounds()) { view->map->removeAnnotation(boundAnnotationID); boundAnnotationID = std::numeric_limits::max(); } else { diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index e88bb5465cd..6b44e633d96 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -83,14 +83,14 @@ void Transform::jumpTo(const CameraOptions& camera) { */ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& animation) { Duration duration = animation.duration.value_or(Duration::zero()); - if (state.bounds == LatLngBounds::unbounded() && !isGestureInProgress() && duration != Duration::zero()) { + if (state.bounds == LatLngBounds() && !isGestureInProgress() && duration != Duration::zero()) { // reuse flyTo, without exaggerated animation, to achieve constant ground speed. return flyTo(camera, animation, true); } const EdgeInsets& padding = camera.padding.value_or(state.edgeInsets); LatLng startLatLng = getLatLng(LatLng::Unwrapped); const LatLng& unwrappedLatLng = camera.center.value_or(startLatLng); - const LatLng& latLng = state.bounds != LatLngBounds::unbounded() ? unwrappedLatLng : unwrappedLatLng.wrapped(); + const LatLng& latLng = state.bounds != LatLngBounds() ? unwrappedLatLng : unwrappedLatLng.wrapped(); double zoom = camera.zoom.value_or(getZoom()); double bearing = camera.bearing ? -*camera.bearing * util::DEG2RAD : getBearing(); double pitch = camera.pitch ? *camera.pitch * util::DEG2RAD : getPitch(); @@ -102,7 +102,7 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim return; } - if (state.bounds == LatLngBounds::unbounded()) { + if (state.bounds == LatLngBounds()) { if (isGestureInProgress()) { // If gesture in progress, we transfer the wrap rounds from the end longitude into // start, so the "scroll effect" of rounding the world is the same while assuring the diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index 61007422cb2..f3cd8c3886b 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -10,11 +10,7 @@ namespace mbgl { TransformState::TransformState(ConstrainMode constrainMode_, ViewportMode viewportMode_) - : bounds(LatLngBounds::unbounded()) - , constrainMode(constrainMode_) - , viewportMode(viewportMode_) -{ -} + : bounds(LatLngBounds()), constrainMode(constrainMode_), viewportMode(viewportMode_) {} #pragma mark - Matrix diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index 0eebc93f32c..9e37f97b8bd 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -316,7 +316,7 @@ TEST(Map, DefaultBoundOptions) { EXPECT_EQ(*bounds.minZoom, util::MIN_ZOOM); EXPECT_EQ(*bounds.maxZoom, util::DEFAULT_MAX_ZOOM); - EXPECT_EQ(*bounds.bounds, LatLngBounds::unbounded()); + EXPECT_EQ(*bounds.bounds, LatLngBounds()); } TEST(Map, MapOptions) { @@ -1053,4 +1053,4 @@ TEST(Map, NoHangOnMissingImage) { test.map.jumpTo(test.map.getStyle().getDefaultCamera()); // The test passes if the following call does not hang. test.frontend.render(test.map); -} \ No newline at end of file +} diff --git a/test/map/transform.test.cpp b/test/map/transform.test.cpp index 84fdb06b211..95fb744206e 100644 --- a/test/map/transform.test.cpp +++ b/test/map/transform.test.cpp @@ -609,7 +609,7 @@ TEST(Transform, LatLngBounds) { transform.jumpTo(CameraOptions().withCenter(LatLng()).withZoom(transform.getState().getMaxZoom())); // Default bounds. - ASSERT_EQ(transform.getState().getLatLngBounds(), LatLngBounds::unbounded()); + ASSERT_EQ(transform.getState().getLatLngBounds(), LatLngBounds()); ASSERT_EQ(transform.getLatLng(), nullIsland); // Invalid bounds. @@ -617,7 +617,7 @@ TEST(Transform, LatLngBounds) { transform.setLatLngBounds(LatLngBounds::empty()); ASSERT_TRUE(false) << "Should throw"; } catch (...) { - ASSERT_EQ(transform.getState().getLatLngBounds(), LatLngBounds::unbounded()); + ASSERT_EQ(transform.getState().getLatLngBounds(), LatLngBounds()); } transform.jumpTo(CameraOptions().withCenter(sanFrancisco));