mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Added support for local (file:) URLs
This commit is contained in:
parent
d7fe0fa9bf
commit
65b74b146d
@ -26,13 +26,16 @@ void TileLoader::loadTilesAsync(QList<Tile> &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<Tile> &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
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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<TileMatrix> _matrixes;
|
||||
|
Loading…
Reference in New Issue
Block a user