summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnder Conselvan de Oliveira <ander.deoliveira@mapbox.com>2019-11-04 08:12:23 +0200
committerAnder Conselvan de Oliveira <ander.deoliveira@mapbox.com>2019-11-13 13:31:01 +0200
commit4c1d03c257754ecc1555f3e31b3c6ccf45c4bf7b (patch)
treed6bd914727d337216e269b08b139a87bca7f41d4
parent089ff8e2b34583de6c989c05a0771b108b3c82f0 (diff)
downloadqtlocation-mapboxgl-4c1d03c257754ecc1555f3e31b3c6ccf45c4bf7b.tar.gz
[core] Fix MapSnapshotter build failure on Windows
MSVC implementation of std::promise is buggy and only works with types that can be default-constructed. To avoid a compilation failure in the instantiation of ask() inside MapSnapshotter::getRegion(), which creates a std::promise<LanLngBounds>, make LatLngBounds' default constructor public.
-rw-r--r--benchmark/fixtures/api/cache.dbbin1298432 -> 1298432 bytes
-rw-r--r--include/mbgl/util/geo.hpp9
-rw-r--r--platform/android/src/native_map_view.cpp2
-rw-r--r--platform/glfw/glfw_view.cpp11
-rw-r--r--src/mbgl/map/transform.cpp6
-rw-r--r--src/mbgl/map/transform_state.cpp6
-rw-r--r--test/map/map.test.cpp4
-rw-r--r--test/map/transform.test.cpp4
8 files changed, 16 insertions, 26 deletions
diff --git a/benchmark/fixtures/api/cache.db b/benchmark/fixtures/api/cache.db
index 64cd376892..5978c1659d 100644
--- a/benchmark/fixtures/api/cache.db
+++ b/benchmark/fixtures/api/cache.db
Binary files differ
diff --git a/include/mbgl/util/geo.hpp b/include/mbgl/util/geo.hpp
index 170eca4f0a..9e1ecfff91 100644
--- a/include/mbgl/util/geo.hpp
+++ b/include/mbgl/util/geo.hpp
@@ -105,14 +105,12 @@ public:
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 @@ private:
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 8cb637fa38..2b0971599d 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::Object<mbgl::an
if (jBounds) {
bounds.withLatLngBounds(mbgl::android::LatLngBounds::getLatLngBounds(env, jBounds));
} else {
- bounds.withLatLngBounds(mbgl::LatLngBounds::unbounded());
+ bounds.withLatLngBounds(mbgl::LatLngBounds());
}
map->setBounds(bounds);
}
diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp
index c39b2c904a..9a2fefaade 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<mbgl::LatLngBounds> 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<mbgl::AnnotationID>::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<mbgl::AnnotationID>::max();
} else {
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp
index e88bb5465c..6b44e633d9 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 61007422cb..f3cd8c3886 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 0eebc93f32..9e37f97b8b 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 84fdb06b21..95fb744206 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));