From 7e98227c708f086ca8cf362209e04707241aaa9a Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Sun, 11 Jul 2021 20:59:53 -0500 Subject: [PATCH] Migrating mapbox-gl-native to maplibre-gl-native --- .gitmodules | 2 +- CMakeLists.txt | 1 + external/mapbox-gl-native | 2 +- external/mapbox-gl-native.cmake | 3 +++ scwx-qt/source/scwx/qt/map/map_widget.cpp | 23 +++++++++++++++++++---- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.gitmodules b/.gitmodules index a07f6e5f..3183b128 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "external/mapbox-gl-native"] path = external/mapbox-gl-native - url = ../mapbox-gl-native.git + url = ../maplibre-gl-native.git [submodule "external/cmake-conan"] path = external/cmake-conan url = https://github.com/conan-io/cmake-conan.git diff --git a/CMakeLists.txt b/CMakeLists.txt index c26af331..724f857a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ project(${PROJECT_NAME} CXX) set(CMAKE_POLICY_DEFAULT_CMP0054 NEW) set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) +set(CMAKE_POLICY_DEFAULT_CMP0079 NEW) enable_testing() diff --git a/external/mapbox-gl-native b/external/mapbox-gl-native index 40b8010d..f424ec41 160000 --- a/external/mapbox-gl-native +++ b/external/mapbox-gl-native @@ -1 +1 @@ -Subproject commit 40b8010d12e82d0e6505aecedd641de70fe41cf7 +Subproject commit f424ec413fecaa0f9121b207d7ae8e667db7ce23 diff --git a/external/mapbox-gl-native.cmake b/external/mapbox-gl-native.cmake index 6c550001..a6239dca 100644 --- a/external/mapbox-gl-native.cmake +++ b/external/mapbox-gl-native.cmake @@ -5,6 +5,9 @@ set(gtest_disable_pthreads ON) set(MBGL_WITH_QT ON) add_subdirectory(mapbox-gl-native) +find_package(ZLIB) +target_link_libraries(mbgl-core PUBLIC ZLIB::ZLIB) + set_target_properties(mbgl-qt PROPERTIES EXCLUDE_FROM_ALL True) set_target_properties(mbgl-test-runner PROPERTIES EXCLUDE_FROM_ALL True) set_target_properties(mbgl-vendor-icu PROPERTIES EXCLUDE_FROM_ALL True) diff --git a/scwx-qt/source/scwx/qt/map/map_widget.cpp b/scwx-qt/source/scwx/qt/map/map_widget.cpp index 40b9e88f..bc052287 100644 --- a/scwx-qt/source/scwx/qt/map/map_widget.cpp +++ b/scwx-qt/source/scwx/qt/map/map_widget.cpp @@ -16,6 +16,20 @@ namespace scwx namespace qt { +typedef std::pair MapStyle; + +// clang-format off +static const MapStyle streets { "mapbox://styles/mapbox/streets-v11", "Streets"}; +static const MapStyle outdoors { "mapbox://styles/mapbox/outdoors-v11", "Outdoors"}; +static const MapStyle light { "mapbox://styles/mapbox/light-v10", "Light"}; +static const MapStyle dark { "mapbox://styles/mapbox/dark-v10", "Dark" }; +static const MapStyle satellite { "mapbox://styles/mapbox/satellite-v9", "Satellite" }; +static const MapStyle satelliteStreets { "mapbox://styles/mapbox/satellite-streets-v11", "Satellite Streets" }; +// clang-format on + +static const std::array mapboxStyles_ = { + {streets, outdoors, light, dark, satellite, satelliteStreets}}; + MapWidget::MapWidget(const QMapboxGLSettings& settings) : settings_(settings) { setFocusPolicy(Qt::StrongFocus); @@ -35,12 +49,13 @@ qreal MapWidget::pixelRatio() void MapWidget::changeStyle() { - static uint8_t currentStyleIndex; + static uint8_t currentStyleIndex = 0; - auto& styles = QMapbox::defaultStyles(); + auto& styles = mapboxStyles_; - map_->setStyleUrl(styles[currentStyleIndex].first); - setWindowTitle(QString("Mapbox GL: ") + styles[currentStyleIndex].second); + map_->setStyleUrl(styles[currentStyleIndex].first.c_str()); + setWindowTitle(QString("Mapbox GL: ") + + styles[currentStyleIndex].second.c_str()); if (++currentStyleIndex == styles.size()) {