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++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
Tile &t = list[i];
|
Tile &t = list[i];
|
||||||
QString file = tileFile(t);
|
QString file(tileFile(t));
|
||||||
QFileInfo fi(file);
|
QFileInfo fi(file);
|
||||||
|
QUrl url(tileUrl(t));
|
||||||
|
|
||||||
if (!fi.exists())
|
if (url.isLocalFile())
|
||||||
dl.append(Download(tileUrl(t), file));
|
loadTileFile(t, url.toLocalFile());
|
||||||
else
|
else if (fi.exists())
|
||||||
loadTileFile(t, file);
|
loadTileFile(t, file);
|
||||||
|
else
|
||||||
|
dl.append(Download(tileUrl(t), file));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dl.empty())
|
if (!dl.empty())
|
||||||
@ -45,13 +48,16 @@ void TileLoader::loadTilesSync(QList<Tile> &list)
|
|||||||
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
Tile &t = list[i];
|
Tile &t = list[i];
|
||||||
QString file = tileFile(t);
|
QString file(tileFile(t));
|
||||||
QFileInfo fi(file);
|
QFileInfo fi(file);
|
||||||
|
QUrl url(tileUrl(t));
|
||||||
|
|
||||||
if (!fi.exists())
|
if (url.isLocalFile())
|
||||||
dl.append(Download(tileUrl(t), file));
|
loadTileFile(t, url.toLocalFile());
|
||||||
else
|
else if (fi.exists())
|
||||||
loadTileFile(t, file);
|
loadTileFile(t, file);
|
||||||
|
else
|
||||||
|
dl.append(Download(tileUrl(t), file));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dl.empty())
|
if (dl.empty())
|
||||||
@ -84,7 +90,7 @@ void TileLoader::clearCache()
|
|||||||
_downloader->clearErrors();
|
_downloader->clearErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TileLoader::tileUrl(const Tile &tile) const
|
QUrl TileLoader::tileUrl(const Tile &tile) const
|
||||||
{
|
{
|
||||||
QString url(_url);
|
QString url(_url);
|
||||||
|
|
||||||
@ -101,7 +107,7 @@ QString TileLoader::tileUrl(const Tile &tile) const
|
|||||||
url.replace("$y", QString::number(tile.xy().y()));
|
url.replace("$y", QString::number(tile.xy().y()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return url;
|
return QUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TileLoader::tileFile(const Tile &tile) const
|
QString TileLoader::tileFile(const Tile &tile) const
|
||||||
|
@ -26,7 +26,7 @@ signals:
|
|||||||
void finished();
|
void finished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString tileUrl(const Tile &tile) const;
|
QUrl tileUrl(const Tile &tile) const;
|
||||||
QString tileFile(const Tile &tile) const;
|
QString tileFile(const Tile &tile) const;
|
||||||
|
|
||||||
Downloader *_downloader;
|
Downloader *_downloader;
|
||||||
|
@ -277,7 +277,7 @@ bool WMTS::parseCapabilities(const QString &path, const Setup &setup)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WMTS::getCapabilities(const QString &url, const QString &file,
|
bool WMTS::downloadCapabilities(const QString &url, const QString &file,
|
||||||
const Authorization &authorization)
|
const Authorization &authorization)
|
||||||
{
|
{
|
||||||
Downloader d;
|
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)
|
WMTS::WMTS(const QString &file, const WMTS::Setup &setup) : _valid(false)
|
||||||
{
|
{
|
||||||
QString capaUrl = setup.rest() ? setup.url() :
|
QUrl url(setup.rest() ? setup.url() : QString(
|
||||||
QString("%1%2service=WMTS&Version=1.0.0&request=GetCapabilities")
|
"%1%2service=WMTS&Version=1.0.0&request=GetCapabilities").arg(setup.url(),
|
||||||
.arg(setup.url(), setup.url().contains('?') ? "&" : "?");
|
setup.url().contains('?') ? "&" : "?"));
|
||||||
|
|
||||||
if (!QFileInfo(file).exists())
|
if (!url.isLocalFile() && !QFileInfo(file).exists())
|
||||||
if (!getCapabilities(capaUrl, file, setup.authorization()))
|
if (!downloadCapabilities(url.toString(), file, setup.authorization()))
|
||||||
return;
|
return;
|
||||||
if (!parseCapabilities(file, setup))
|
if (!parseCapabilities(url.isLocalFile() ? url.toLocalFile() : file, setup))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QString style = setup.style().isEmpty() ? "default" : setup.style();
|
QString style = setup.style().isEmpty() ? "default" : setup.style();
|
||||||
|
@ -139,7 +139,7 @@ private:
|
|||||||
void contents(QXmlStreamReader &reader, CTX &ctx);
|
void contents(QXmlStreamReader &reader, CTX &ctx);
|
||||||
void capabilities(QXmlStreamReader &reader, CTX &ctx);
|
void capabilities(QXmlStreamReader &reader, CTX &ctx);
|
||||||
bool parseCapabilities(const QString &path, const Setup &setup);
|
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);
|
const Authorization &authorization);
|
||||||
|
|
||||||
QSet<TileMatrix> _matrixes;
|
QSet<TileMatrix> _matrixes;
|
||||||
|
Loading…
Reference in New Issue
Block a user