mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 21:10:04 +00:00
With MapTiler, use https for style URLs
- Eliminates issues with rewriting maptiler:// to incorrect URLs
This commit is contained in:
parent
a74fb22c88
commit
e0c1138250
5 changed files with 49 additions and 19 deletions
|
|
@ -120,8 +120,11 @@ public:
|
||||||
|
|
||||||
std::string mapProviderApiKey = map::GetMapProviderApiKey(mapProvider_);
|
std::string mapProviderApiKey = map::GetMapProviderApiKey(mapProvider_);
|
||||||
|
|
||||||
settings_.setProviderTemplate(mapProviderInfo.providerTemplate_);
|
if (mapProvider_ == map::MapProvider::Mapbox)
|
||||||
settings_.setApiKey(QString {mapProviderApiKey.c_str()});
|
{
|
||||||
|
settings_.setProviderTemplate(mapProviderInfo.providerTemplate_);
|
||||||
|
settings_.setApiKey(QString {mapProviderApiKey.c_str()});
|
||||||
|
}
|
||||||
settings_.setCacheDatabasePath(QString {cacheDbPath.c_str()});
|
settings_.setCacheDatabasePath(QString {cacheDbPath.c_str()});
|
||||||
settings_.setCacheDatabaseMaximumSize(20 * 1024 * 1024);
|
settings_.setCacheDatabaseMaximumSize(20 * 1024 * 1024);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,49 +77,52 @@ static const std::unordered_map<MapProvider, MapProviderInfo> mapProviderInfo_ {
|
||||||
QMapLibre::Settings::ProviderTemplate::MapTilerProvider},
|
QMapLibre::Settings::ProviderTemplate::MapTilerProvider},
|
||||||
.mapStyles_ {
|
.mapStyles_ {
|
||||||
{.name_ {"Satellite"},
|
{.name_ {"Satellite"},
|
||||||
.url_ {"maptiler://maps/hybrid"},
|
.url_ {"https://api.maptiler.com/maps/hybrid/style.json"},
|
||||||
.drawBelow_ {"tunnel"}},
|
.drawBelow_ {"tunnel"}},
|
||||||
{.name_ {"Streets"},
|
{.name_ {"Streets"},
|
||||||
.url_ {"maptiler://maps/streets-v2"},
|
.url_ {"https://api.maptiler.com/maps/streets-v2/style.json"},
|
||||||
.drawBelow_ {"aeroway"}},
|
.drawBelow_ {"aeroway"}},
|
||||||
{.name_ {"Streets Dark"},
|
{.name_ {"Streets Dark"},
|
||||||
.url_ {"maptiler://maps/streets-v2-dark"},
|
.url_ {"https://api.maptiler.com/maps/streets-v2-dark/style.json"},
|
||||||
.drawBelow_ {"aeroway"}},
|
.drawBelow_ {"aeroway"}},
|
||||||
{.name_ {"Basic"},
|
{.name_ {"Basic"},
|
||||||
.url_ {"maptiler://maps/basic-v2"},
|
.url_ {"https://api.maptiler.com/maps/basic-v2/style.json"},
|
||||||
.drawBelow_ {"railway_transit_tunnel", "Transit tunnel"}},
|
.drawBelow_ {"railway_transit_tunnel", "Transit tunnel"}},
|
||||||
{.name_ {"Bright"},
|
{.name_ {"Bright"},
|
||||||
.url_ {"maptiler://maps/bright-v2"},
|
.url_ {"https://api.maptiler.com/maps/bright-v2/style.json"},
|
||||||
.drawBelow_ {"ferry"}},
|
.drawBelow_ {"ferry"}},
|
||||||
{.name_ {"Dataviz"},
|
{.name_ {"Dataviz"},
|
||||||
.url_ {"maptiler://maps/dataviz"},
|
.url_ {"https://api.maptiler.com/maps/dataviz/style.json"},
|
||||||
.drawBelow_ {"aeroway"}},
|
.drawBelow_ {"aeroway"}},
|
||||||
{.name_ {"Dataviz Dark"},
|
{.name_ {"Dataviz Dark"},
|
||||||
.url_ {"maptiler://maps/dataviz-dark"},
|
.url_ {"https://api.maptiler.com/maps/dataviz-dark/style.json"},
|
||||||
.drawBelow_ {"aeroway"}},
|
.drawBelow_ {"aeroway"}},
|
||||||
{.name_ {"Outdoor"},
|
{.name_ {"Outdoor"},
|
||||||
.url_ {"maptiler://maps/outdoor-v2"},
|
.url_ {"https://api.maptiler.com/maps/outdoor-v2/style.json"},
|
||||||
.drawBelow_ {"aeroway_runway", "Aeroway"}},
|
.drawBelow_ {"aeroway_runway", "Aeroway"}},
|
||||||
{.name_ {"Swisstopo"},
|
{.name_ {"Swisstopo"},
|
||||||
.url_ {"maptiler://maps/ch-swisstopo-lbm"},
|
.url_ {"https://api.maptiler.com/maps/ch-swisstopo-lbm/style.json"},
|
||||||
.drawBelow_ {"pattern_landcover_vineyard", "Vineyard pattern"}},
|
.drawBelow_ {"pattern_landcover_vineyard", "Vineyard pattern"}},
|
||||||
{.name_ {"Swisstopo Dark"},
|
{.name_ {"Swisstopo Dark"},
|
||||||
.url_ {"maptiler://maps/ch-swisstopo-lbm-dark"},
|
.url_ {
|
||||||
|
"https://api.maptiler.com/maps/ch-swisstopo-lbm-dark/style.json"},
|
||||||
.drawBelow_ {"pattern_landcover_vineyard", "Vineyard pattern"}},
|
.drawBelow_ {"pattern_landcover_vineyard", "Vineyard pattern"}},
|
||||||
{.name_ {"Swisstopo Grey"},
|
{.name_ {"Swisstopo Grey"},
|
||||||
.url_ {"maptiler://maps/ch-swisstopo-lbm-grey"},
|
.url_ {
|
||||||
|
"https://api.maptiler.com/maps/ch-swisstopo-lbm-grey/style.json"},
|
||||||
.drawBelow_ {"pattern_landcover_vineyard", "Vineyard pattern"}},
|
.drawBelow_ {"pattern_landcover_vineyard", "Vineyard pattern"}},
|
||||||
{.name_ {"Swisstopo Vivid"},
|
{.name_ {"Swisstopo Vivid"},
|
||||||
.url_ {"maptiler://maps/ch-swisstopo-lbm-vivid"},
|
.url_ {"https://api.maptiler.com/maps/ch-swisstopo-lbm-vivid/"
|
||||||
|
"style.json"},
|
||||||
.drawBelow_ {"pattern_landcover_vineyard", "Vineyard pattern"}},
|
.drawBelow_ {"pattern_landcover_vineyard", "Vineyard pattern"}},
|
||||||
{.name_ {"Topo"},
|
{.name_ {"Topo"},
|
||||||
.url_ {"maptiler://maps/topo-v2"},
|
.url_ {"https://api.maptiler.com/maps/topo-v2/style.json"},
|
||||||
.drawBelow_ {"aeroway_runway", "Runway"}},
|
.drawBelow_ {"aeroway_runway", "Runway"}},
|
||||||
{.name_ {"Topo Dark"},
|
{.name_ {"Topo Dark"},
|
||||||
.url_ {"maptiler://maps/topo-v2-dark"},
|
.url_ {"https://api.maptiler.com/maps/topo-v2-dark/style.json"},
|
||||||
.drawBelow_ {"aeroway_runway", "Runway"}},
|
.drawBelow_ {"aeroway_runway", "Runway"}},
|
||||||
{.name_ {"Winter"},
|
{.name_ {"Winter"},
|
||||||
.url_ {"maptiler://maps/winter-v2"},
|
.url_ {"https://api.maptiler.com/maps/winter-v2/style.json"},
|
||||||
.drawBelow_ {"aeroway_runway", "Aeroway"}}}}},
|
.drawBelow_ {"aeroway_runway", "Aeroway"}}}}},
|
||||||
{MapProvider::Unknown, MapProviderInfo {}}};
|
{MapProvider::Unknown, MapProviderInfo {}}};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -737,7 +737,8 @@ void MapWidget::SetMapStyle(const std::string& styleName)
|
||||||
|
|
||||||
logger_->debug("Updating style: {}", styles[i].name_);
|
logger_->debug("Updating style: {}", styles[i].name_);
|
||||||
|
|
||||||
p->map_->setStyleUrl(styles[i].url_.c_str());
|
util::maplibre::SetMapStyleUrl(
|
||||||
|
p->map_, p->mapProvider_, styles[i].url_);
|
||||||
|
|
||||||
if (++p->currentStyleIndex_ == styles.size())
|
if (++p->currentStyleIndex_ == styles.size())
|
||||||
{
|
{
|
||||||
|
|
@ -763,7 +764,8 @@ void MapWidget::changeStyle()
|
||||||
|
|
||||||
logger_->debug("Updating style: {}", styles[p->currentStyleIndex_].name_);
|
logger_->debug("Updating style: {}", styles[p->currentStyleIndex_].name_);
|
||||||
|
|
||||||
p->map_->setStyleUrl(styles[p->currentStyleIndex_].url_.c_str());
|
util::maplibre::SetMapStyleUrl(
|
||||||
|
p->map_, p->mapProvider_, styles[p->currentStyleIndex_].url_);
|
||||||
|
|
||||||
if (++p->currentStyleIndex_ == styles.size())
|
if (++p->currentStyleIndex_ == styles.size())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,21 @@ glm::vec2 LatLongToScreenCoordinate(const QMapLibre::Coordinate& coordinate)
|
||||||
return screen;
|
return screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetMapStyleUrl(const std::shared_ptr<QMapLibre::Map>& map,
|
||||||
|
map::MapProvider mapProvider,
|
||||||
|
const std::string& url)
|
||||||
|
{
|
||||||
|
QString qUrl = QString::fromStdString(url);
|
||||||
|
|
||||||
|
if (mapProvider == map::MapProvider::MapTiler)
|
||||||
|
{
|
||||||
|
qUrl.append("?key=");
|
||||||
|
qUrl.append(map::GetMapProviderApiKey(mapProvider));
|
||||||
|
}
|
||||||
|
|
||||||
|
map->setStyleUrl(qUrl);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace maplibre
|
} // namespace maplibre
|
||||||
} // namespace util
|
} // namespace util
|
||||||
} // namespace qt
|
} // namespace qt
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <scwx/qt/map/map_provider.hpp>
|
||||||
|
|
||||||
|
#include <QMapLibre/Map>
|
||||||
#include <QMapLibre/Types>
|
#include <QMapLibre/Types>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
#include <units/length.h>
|
#include <units/length.h>
|
||||||
|
|
@ -31,6 +34,10 @@ bool IsPointInPolygon(const std::vector<glm::vec2>& vertices,
|
||||||
|
|
||||||
glm::vec2 LatLongToScreenCoordinate(const QMapLibre::Coordinate& coordinate);
|
glm::vec2 LatLongToScreenCoordinate(const QMapLibre::Coordinate& coordinate);
|
||||||
|
|
||||||
|
void SetMapStyleUrl(const std::shared_ptr<QMapLibre::Map>& map,
|
||||||
|
map::MapProvider mapProvider,
|
||||||
|
const std::string& url);
|
||||||
|
|
||||||
} // namespace maplibre
|
} // namespace maplibre
|
||||||
} // namespace util
|
} // namespace util
|
||||||
} // namespace qt
|
} // namespace qt
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue