From d905abd3e7656fd5913dfb81e36be477936763bf Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Wed, 6 Mar 2024 23:54:27 -0600 Subject: [PATCH] Map provider test fixes --- scwx-qt/source/scwx/qt/map/map_provider.cpp | 2 +- test/source/scwx/qt/map/map_provider.test.cpp | 28 ++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/scwx-qt/source/scwx/qt/map/map_provider.cpp b/scwx-qt/source/scwx/qt/map/map_provider.cpp index 7d916072..1648bdc5 100644 --- a/scwx-qt/source/scwx/qt/map/map_provider.cpp +++ b/scwx-qt/source/scwx/qt/map/map_provider.cpp @@ -51,7 +51,7 @@ static const std::unordered_map mapProviderInfo_ { {.name_ {"Bubble"}, .url_ { "mapbox://styles/mapbox-map-design/cl4wxue5j000c14r17uqrjpqb"}, - .drawBelow_ {mapboxDrawBelow_}}, + .drawBelow_ {"com\\.mapbox\\.annotations\\.points"}}, {.name_ {"Cali Terrain"}, .url_ {"mapbox://styles/mapbox/cjerxnqt3cgvp2rmyuxbeqme7"}, .drawBelow_ {"major roads casing"}}, diff --git a/test/source/scwx/qt/map/map_provider.test.cpp b/test/source/scwx/qt/map/map_provider.test.cpp index 3a6a64a5..0f7aff58 100644 --- a/test/source/scwx/qt/map/map_provider.test.cpp +++ b/test/source/scwx/qt/map/map_provider.test.cpp @@ -1,4 +1,6 @@ #include +#include +#include #include #include @@ -47,15 +49,27 @@ TEST_P(ByMapProviderTest, MapProviderLayers) // Configure QMapLibre QMapLibre::Settings mapSettings {}; - mapSettings.setProviderTemplate(mapProviderInfo.providerTemplate_); - mapSettings.setApiKey(QString::fromStdString(apiKey)); + if (mapProvider == map::MapProvider::Mapbox) + { + mapSettings.setProviderTemplate(mapProviderInfo.providerTemplate_); + mapSettings.setApiKey(QString::fromStdString(apiKey)); + } + else if (mapProvider == map::MapProvider::MapTiler) + { + settings::GeneralSettings::Instance().maptiler_api_key().SetValue(apiKey); + } - QMapLibre::Map map(nullptr, mapSettings, QSize(1, 1)); + std::shared_ptr mapContext = + std::make_shared(); + std::shared_ptr map = + std::make_shared(nullptr, mapSettings, QSize(1, 1)); + mapContext->set_map(map); + mapContext->set_map_provider(mapProvider); application.processEvents(); // Connect style load completion signal QObject::connect( - &map, + map.get(), &QMapLibre::Map::mapChanged, [&](QMapLibre::Map::MapChange mapChange) { @@ -88,7 +102,7 @@ TEST_P(ByMapProviderTest, MapProviderLayers) // Load style timeout = false; - map.setStyleUrl(QString::fromStdString(mapStyle.url_)); + util::maplibre::SetMapStyleUrl(mapContext, mapStyle.url_); timeoutTimer.start(5000ms); application.exec(); timeoutTimer.stop(); @@ -97,12 +111,12 @@ TEST_P(ByMapProviderTest, MapProviderLayers) if (!timeout) { // Print layer names for debug - std::string layerIdsString = map.layerIds().join(", ").toStdString(); + std::string layerIdsString = map->layerIds().join(", ").toStdString(); logger_->debug("{} Layers: [{}]", mapStyle.name_, layerIdsString); // Search layer list bool foundMatch = false; - for (const QString& qlayer : map.layerIds()) + for (const QString& qlayer : map->layerIds()) { const std::string layer = qlayer.toStdString();