summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2019-02-26 11:01:45 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2019-02-26 11:32:16 +0200
commita360f2bd6d483951a8d42391bc745ec389d69ec4 (patch)
tree564f9d9cee55799512295b0f49ea04702d0e2c90
parent2e3ffb6980aa4a802e4664a745d1075fe12d8722 (diff)
downloadqtlocation-mapboxgl-upstream/latlngbounds-antimeridian-fix.tar.gz
-rw-r--r--platform/glfw/glfw_view.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp
index d0c8a7be76..fc6611941e 100644
--- a/platform/glfw/glfw_view.cpp
+++ b/platform/glfw/glfw_view.cpp
@@ -12,6 +12,7 @@
#include <mbgl/util/platform.hpp>
#include <mbgl/util/string.hpp>
#include <mbgl/util/chrono.hpp>
+#include <mbgl/util/geo.hpp>
#include <mbgl/renderer/renderer.hpp>
#include <mbgl/renderer/backend_scope.hpp>
#include <mbgl/map/camera.hpp>
@@ -122,6 +123,7 @@ GLFWView::GLFWView(bool fullscreen_, bool benchmark_)
printf("- Prezz `X` to cycle through the viewport modes\n");
printf("- Press `A` to cycle through Mapbox offices in the world + dateline monument\n");
printf("- Press `B` to cycle through the color, stencil, and depth buffer\n");
+ printf("- Press `D` to cycle through camera bounds: inside, crossing IDL at left, crossing IDL at right, and disabled\n");
printf("\n");
printf("- Press `1` through `6` to add increasing numbers of point annotations for testing\n");
printf("- Press `7` through `0` to add increasing numbers of shape annotations for testing\n");
@@ -279,6 +281,45 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action,
case GLFW_KEY_E:
view->toggle3DExtrusions(!view->show3DExtrusions);
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::world()
+ };
+ static size_t nextBound = 0;
+ static mbgl::AnnotationID boundAnnotationID = std::numeric_limits<mbgl::AnnotationID>::max();
+
+ mbgl::LatLngBounds bound = bounds[nextBound++];
+ nextBound = nextBound % bounds.size();
+
+ if (bound == mbgl::LatLngBounds::world()) {
+ view->map->setLatLngBounds({});
+ view->map->removeAnnotation(boundAnnotationID);
+ boundAnnotationID = std::numeric_limits<mbgl::AnnotationID>::max();
+ break;
+ } else {
+ view->map->setLatLngBounds(bound);
+ }
+
+ mbgl::Polygon<double> rect;
+ rect.push_back({
+ mbgl::Point<double>{ bound.west(), bound.north() },
+ mbgl::Point<double>{ bound.east(), bound.north() },
+ mbgl::Point<double>{ bound.east(), bound.south() },
+ mbgl::Point<double>{ bound.west(), bound.south() },
+ });
+
+ auto boundAnnotation = mbgl::FillAnnotation { rect, 0.5f, { view->makeRandomColor() }, { view->makeRandomColor() } };
+
+ if (boundAnnotationID == std::numeric_limits<mbgl::AnnotationID>::max()) {
+ boundAnnotationID = view->map->addAnnotation(boundAnnotation);
+ printf("boundAnnotationID: %ld\n", boundAnnotationID);
+ } else {
+ view->map->updateAnnotation(boundAnnotationID, boundAnnotation);
+ }
+ } break;
}
}