mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-06-19 06:42:31 -04:00
Change Street Map from WikiMedia to OpenStreetMap, as Wikimedia servers are no longer available. For #1709
This commit is contained in:
parent
9ef16315f6
commit
632ce95c26
@ -23,6 +23,7 @@
|
|||||||
#include <QGeoCoordinate>
|
#include <QGeoCoordinate>
|
||||||
#include <QGeoCodingManager>
|
#include <QGeoCodingManager>
|
||||||
#include <QGeoServiceProvider>
|
#include <QGeoServiceProvider>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
#ifdef QT_WEBENGINE_FOUND
|
#ifdef QT_WEBENGINE_FOUND
|
||||||
#include <QtWebEngineWidgets/QWebEngineView>
|
#include <QtWebEngineWidgets/QWebEngineView>
|
||||||
@ -213,6 +214,8 @@ MapGUI::MapGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *featur
|
|||||||
ui->map->setFormat(format);
|
ui->map->setFormat(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearWikiMediaOSMCache();
|
||||||
|
|
||||||
m_osmPort = 0;
|
m_osmPort = 0;
|
||||||
m_templateServer = new OSMTemplateServer(thunderforestAPIKey(), maptilerAPIKey(), m_osmPort);
|
m_templateServer = new OSMTemplateServer(thunderforestAPIKey(), maptilerAPIKey(), m_osmPort);
|
||||||
|
|
||||||
@ -1106,6 +1109,31 @@ void MapGUI::clearOSMCache()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete old cache if it might contain wikimedia OSM images before switch to using OSM directly
|
||||||
|
// as the images are different
|
||||||
|
void MapGUI::clearWikiMediaOSMCache()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
QString cacheCleared = "sdrangel.feature.map/cacheCleared";
|
||||||
|
if (!settings.value(cacheCleared).toBool())
|
||||||
|
{
|
||||||
|
qDebug() << "MapGUI::clearWikiMediaOSMCache: Clearing cache";
|
||||||
|
QDir dir(osmCachePath());
|
||||||
|
if (dir.exists())
|
||||||
|
{
|
||||||
|
QStringList filenames = dir.entryList({"osm_100-l-1-*.png"});
|
||||||
|
for (const auto& filename : filenames)
|
||||||
|
{
|
||||||
|
QFile file(dir.filePath(filename));
|
||||||
|
if (!file.remove()) {
|
||||||
|
qDebug() << "MapGUI::clearWikiMediaOSMCache: Failed to remove " << file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
settings.setValue(cacheCleared, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MapGUI::applyMap2DSettings(bool reloadMap)
|
void MapGUI::applyMap2DSettings(bool reloadMap)
|
||||||
{
|
{
|
||||||
ui->map->setVisible(m_settings.m_map2DEnabled);
|
ui->map->setVisible(m_settings.m_map2DEnabled);
|
||||||
|
@ -218,6 +218,7 @@ private:
|
|||||||
void applyMap3DSettings(bool reloadMap);
|
void applyMap3DSettings(bool reloadMap);
|
||||||
QString osmCachePath();
|
QString osmCachePath();
|
||||||
void clearOSMCache();
|
void clearOSMCache();
|
||||||
|
void clearWikiMediaOSMCache();
|
||||||
void displaySettings();
|
void displaySettings();
|
||||||
bool handleMessage(const Message& message);
|
bool handleMessage(const Message& message);
|
||||||
void geoReply();
|
void geoReply();
|
||||||
|
@ -71,14 +71,14 @@ private slots:
|
|||||||
{
|
{
|
||||||
xml = QString("\
|
xml = QString("\
|
||||||
{\
|
{\
|
||||||
\"UrlTemplate\" : \"https://maps.wikimedia.org/osm-intl/%z/%x/%y%1.png\",\
|
\"UrlTemplate\" : \"https://tile.openstreetmap.org/%z/%x/%y.png\",\
|
||||||
\"ImageFormat\" : \"png\",\
|
\"ImageFormat\" : \"png\",\
|
||||||
\"QImageFormat\" : \"Indexed8\",\
|
\"QImageFormat\" : \"Indexed8\",\
|
||||||
\"ID\" : \"wmf-intl-%2x\",\
|
\"ID\" : \"wmf-intl-1x\",\
|
||||||
\"MaximumZoomLevel\" : 18,\
|
\"MaximumZoomLevel\" : 19,\
|
||||||
\"MapCopyRight\" : \"<a href='https://wikimediafoundation.org/wiki/Terms_of_Use'>WikiMedia Foundation</a>\",\
|
\"MapCopyRight\" : \"<a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a>\",\
|
||||||
\"DataCopyRight\" : \"<a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors\"\
|
\"DataCopyRight\" : \"\"\
|
||||||
}").arg(hiresURL).arg(hires ? 1 : 2);
|
}");
|
||||||
}
|
}
|
||||||
else if (tokens[1] == "/satellite")
|
else if (tokens[1] == "/satellite")
|
||||||
{
|
{
|
||||||
@ -91,7 +91,7 @@ private slots:
|
|||||||
\"ID\" : \"usgs-l7\",\
|
\"ID\" : \"usgs-l7\",\
|
||||||
\"MaximumZoomLevel\" : 20,\
|
\"MaximumZoomLevel\" : 20,\
|
||||||
\"MapCopyRight\" : \"<a href='http://maptiler.com/'>Maptiler</a>\",\
|
\"MapCopyRight\" : \"<a href='http://maptiler.com/'>Maptiler</a>\",\
|
||||||
\"DataCopyRight\" : \"<a href='http://maptiler.com'>Maptiler</a>\"\
|
\"DataCopyRight\" : \"\"\
|
||||||
}").arg(hiresURL).arg(m_maptilerAPIKey);
|
}").arg(hiresURL).arg(m_maptilerAPIKey);
|
||||||
}
|
}
|
||||||
else if (tokens[1].contains("transit"))
|
else if (tokens[1].contains("transit"))
|
||||||
@ -110,7 +110,7 @@ private slots:
|
|||||||
\"ID\" : \"%3\",\
|
\"ID\" : \"%3\",\
|
||||||
\"MaximumZoomLevel\" : 20,\
|
\"MaximumZoomLevel\" : 20,\
|
||||||
\"MapCopyRight\" : \"<a href='https://carto.com'>CartoDB</a>\",\
|
\"MapCopyRight\" : \"<a href='https://carto.com'>CartoDB</a>\",\
|
||||||
\"DataCopyRight\" : \"<a href='https://carto.com'>CartoDB</a>\"\
|
\"DataCopyRight\" : \"\"\
|
||||||
}").arg(hiresURL).arg(mapUrl[idx]).arg(mapId[idx]);
|
}").arg(hiresURL).arg(mapUrl[idx]).arg(mapId[idx]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user