mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-12-04 16:29:09 +01:00
Compare commits
3 Commits
c449024584
...
1dc963b133
Author | SHA1 | Date | |
---|---|---|---|
1dc963b133 | |||
f0036bfd28 | |||
688861bf65 |
@ -18,9 +18,8 @@ OnlineMap::OnlineMap(const QString &fileName, const QString &name,
|
|||||||
{
|
{
|
||||||
_tileLoader = new TileLoader(QDir(ProgramPaths::tilesDir()).filePath(_name),
|
_tileLoader = new TileLoader(QDir(ProgramPaths::tilesDir()).filePath(_name),
|
||||||
this);
|
this);
|
||||||
_tileLoader->setUrl(url);
|
_tileLoader->setUrl(url, quadTiles ? TileLoader::QuadTiles : TileLoader::XYZ);
|
||||||
_tileLoader->setHeaders(headers);
|
_tileLoader->setHeaders(headers);
|
||||||
_tileLoader->setQuadTiles(quadTiles);
|
|
||||||
connect(_tileLoader, &TileLoader::finished, this, &OnlineMap::tilesLoaded);
|
connect(_tileLoader, &TileLoader::finished, this, &OnlineMap::tilesLoaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ static QString quadKey(const QPoint &xy, int zoom)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TileLoader::TileLoader(const QString &dir, QObject *parent)
|
TileLoader::TileLoader(const QString &dir, QObject *parent)
|
||||||
: QObject(parent), _dir(dir), _scaledSize(0), _quadTiles(false)
|
: QObject(parent), _urlType(XYZ), _dir(dir), _scaledSize(0)
|
||||||
{
|
{
|
||||||
if (!QDir().mkpath(_dir))
|
if (!QDir().mkpath(_dir))
|
||||||
qWarning("%s: %s", qPrintable(_dir), "Error creating tiles directory");
|
qWarning("%s: %s", qPrintable(_dir), "Error creating tiles directory");
|
||||||
@ -176,19 +176,21 @@ QUrl TileLoader::tileUrl(const FetchTile &tile) const
|
|||||||
{
|
{
|
||||||
QString url(_url);
|
QString url(_url);
|
||||||
|
|
||||||
if (!tile.bbox().isNull()) {
|
switch (_urlType) {
|
||||||
QString bbox = QString("%1,%2,%3,%4").arg(
|
case BoundingBox:
|
||||||
QString::number(tile.bbox().left(), 'f', 6),
|
url.replace("$bbox", QString("%1,%2,%3,%4").arg(
|
||||||
QString::number(tile.bbox().bottom(), 'f', 6),
|
QString::number(tile.bbox().left(), 'f', 6),
|
||||||
QString::number(tile.bbox().right(), 'f', 6),
|
QString::number(tile.bbox().bottom(), 'f', 6),
|
||||||
QString::number(tile.bbox().top(), 'f', 6));
|
QString::number(tile.bbox().right(), 'f', 6),
|
||||||
url.replace("$bbox", bbox);
|
QString::number(tile.bbox().top(), 'f', 6)));
|
||||||
} else if (_quadTiles) {
|
break;
|
||||||
url.replace("$quadkey", quadKey(tile.xy(), tile.zoom().toInt()));
|
case QuadTiles:
|
||||||
} else {
|
url.replace("$quadkey", quadKey(tile.xy(), tile.zoom().toInt()));
|
||||||
url.replace("$z", tile.zoom().toString());
|
break;
|
||||||
url.replace("$x", QString::number(tile.xy().x()));
|
default:
|
||||||
url.replace("$y", QString::number(tile.xy().y()));
|
url.replace("$z", tile.zoom().toString());
|
||||||
|
url.replace("$x", QString::number(tile.xy().x()));
|
||||||
|
url.replace("$y", QString::number(tile.xy().y()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return QUrl(url);
|
return QUrl(url);
|
||||||
|
@ -11,12 +11,17 @@ class TileLoader : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum UrlType {
|
||||||
|
XYZ,
|
||||||
|
QuadTiles,
|
||||||
|
BoundingBox
|
||||||
|
};
|
||||||
|
|
||||||
TileLoader(const QString &dir, QObject *parent = 0);
|
TileLoader(const QString &dir, QObject *parent = 0);
|
||||||
|
|
||||||
void setUrl(const QString &url) {_url = url;}
|
void setUrl(const QString &url, UrlType type) {_url = url; _urlType = type;}
|
||||||
void setHeaders(const QList<HTTPHeader> &headers) {_headers = headers;}
|
void setHeaders(const QList<HTTPHeader> &headers) {_headers = headers;}
|
||||||
void setScaledSize(int size);
|
void setScaledSize(int size);
|
||||||
void setQuadTiles(bool quadTiles) {_quadTiles = quadTiles;}
|
|
||||||
|
|
||||||
void loadTilesAsync(QVector<FetchTile> &list);
|
void loadTilesAsync(QVector<FetchTile> &list);
|
||||||
void loadTilesSync(QVector<FetchTile> &list);
|
void loadTilesSync(QVector<FetchTile> &list);
|
||||||
@ -31,10 +36,10 @@ private:
|
|||||||
|
|
||||||
Downloader *_downloader;
|
Downloader *_downloader;
|
||||||
QString _url;
|
QString _url;
|
||||||
|
UrlType _urlType;
|
||||||
QString _dir;
|
QString _dir;
|
||||||
QList<HTTPHeader> _headers;
|
QList<HTTPHeader> _headers;
|
||||||
int _scaledSize;
|
int _scaledSize;
|
||||||
bool _quadTiles;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TILELOADER_H
|
#endif // TILELOADER_H
|
||||||
|
@ -85,7 +85,7 @@ WMSMap::WMSMap(const QString &fileName, const QString &name,
|
|||||||
|
|
||||||
void WMSMap::init()
|
void WMSMap::init()
|
||||||
{
|
{
|
||||||
_tileLoader->setUrl(tileUrl());
|
_tileLoader->setUrl(tileUrl(), TileLoader::BoundingBox);
|
||||||
_bounds = RectD(_wms->bbox(), _wms->projection());
|
_bounds = RectD(_wms->bbox(), _wms->projection());
|
||||||
computeZooms();
|
computeZooms();
|
||||||
updateTransform();
|
updateTransform();
|
||||||
|
@ -31,7 +31,7 @@ WMTSMap::WMTSMap(const QString &fileName, const QString &name,
|
|||||||
|
|
||||||
void WMTSMap::init()
|
void WMTSMap::init()
|
||||||
{
|
{
|
||||||
_tileLoader->setUrl(_wmts->tileUrl());
|
_tileLoader->setUrl(_wmts->tileUrl(), TileLoader::XYZ);
|
||||||
_bounds = RectD(_wmts->bbox(), _wmts->projection());
|
_bounds = RectD(_wmts->bbox(), _wmts->projection());
|
||||||
updateTransform();
|
updateTransform();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user