diff --git a/src/map/tileloader.cpp b/src/map/tileloader.cpp index 41054002..5549b328 100644 --- a/src/map/tileloader.cpp +++ b/src/map/tileloader.cpp @@ -26,13 +26,16 @@ void TileLoader::loadTilesAsync(QList &list) for (int i = 0; i < list.size(); i++) { Tile &t = list[i]; - QString file = tileFile(t); + QString file(tileFile(t)); QFileInfo fi(file); + QUrl url(tileUrl(t)); - if (!fi.exists()) - dl.append(Download(tileUrl(t), file)); - else + if (url.isLocalFile()) + loadTileFile(t, url.toLocalFile()); + else if (fi.exists()) loadTileFile(t, file); + else + dl.append(Download(tileUrl(t), file)); } if (!dl.empty()) @@ -45,13 +48,16 @@ void TileLoader::loadTilesSync(QList &list) for (int i = 0; i < list.size(); i++) { Tile &t = list[i]; - QString file = tileFile(t); + QString file(tileFile(t)); QFileInfo fi(file); + QUrl url(tileUrl(t)); - if (!fi.exists()) - dl.append(Download(tileUrl(t), file)); - else + if (url.isLocalFile()) + loadTileFile(t, url.toLocalFile()); + else if (fi.exists()) loadTileFile(t, file); + else + dl.append(Download(tileUrl(t), file)); } if (dl.empty()) @@ -84,7 +90,7 @@ void TileLoader::clearCache() _downloader->clearErrors(); } -QString TileLoader::tileUrl(const Tile &tile) const +QUrl TileLoader::tileUrl(const Tile &tile) const { QString url(_url); @@ -101,7 +107,7 @@ QString TileLoader::tileUrl(const Tile &tile) const url.replace("$y", QString::number(tile.xy().y())); } - return url; + return QUrl(url); } QString TileLoader::tileFile(const Tile &tile) const diff --git a/src/map/tileloader.h b/src/map/tileloader.h index 2cad88f2..ee01fc71 100644 --- a/src/map/tileloader.h +++ b/src/map/tileloader.h @@ -26,7 +26,7 @@ signals: void finished(); private: - QString tileUrl(const Tile &tile) const; + QUrl tileUrl(const Tile &tile) const; QString tileFile(const Tile &tile) const; Downloader *_downloader; diff --git a/src/map/wmts.cpp b/src/map/wmts.cpp index 4056de65..82e86c33 100644 --- a/src/map/wmts.cpp +++ b/src/map/wmts.cpp @@ -277,7 +277,7 @@ bool WMTS::parseCapabilities(const QString &path, const Setup &setup) return true; } -bool WMTS::getCapabilities(const QString &url, const QString &file, +bool WMTS::downloadCapabilities(const QString &url, const QString &file, const Authorization &authorization) { Downloader d; @@ -300,14 +300,14 @@ bool WMTS::getCapabilities(const QString &url, const QString &file, WMTS::WMTS(const QString &file, const WMTS::Setup &setup) : _valid(false) { - QString capaUrl = setup.rest() ? setup.url() : - QString("%1%2service=WMTS&Version=1.0.0&request=GetCapabilities") - .arg(setup.url(), setup.url().contains('?') ? "&" : "?"); + QUrl url(setup.rest() ? setup.url() : QString( + "%1%2service=WMTS&Version=1.0.0&request=GetCapabilities").arg(setup.url(), + setup.url().contains('?') ? "&" : "?")); - if (!QFileInfo(file).exists()) - if (!getCapabilities(capaUrl, file, setup.authorization())) + if (!url.isLocalFile() && !QFileInfo(file).exists()) + if (!downloadCapabilities(url.toString(), file, setup.authorization())) return; - if (!parseCapabilities(file, setup)) + if (!parseCapabilities(url.isLocalFile() ? url.toLocalFile() : file, setup)) return; QString style = setup.style().isEmpty() ? "default" : setup.style(); diff --git a/src/map/wmts.h b/src/map/wmts.h index d7d8d673..9e92caeb 100644 --- a/src/map/wmts.h +++ b/src/map/wmts.h @@ -139,7 +139,7 @@ private: void contents(QXmlStreamReader &reader, CTX &ctx); void capabilities(QXmlStreamReader &reader, CTX &ctx); bool parseCapabilities(const QString &path, const Setup &setup); - bool getCapabilities(const QString &url, const QString &file, + bool downloadCapabilities(const QString &url, const QString &file, const Authorization &authorization); QSet _matrixes;