1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-12-04 08:19:10 +01:00

Compare commits

...

3 Commits

Author SHA1 Message Date
1dc963b133 Revert "Removed SDK/buildtools workaround"
This reverts commit f0036bfd28.
2023-06-23 10:08:30 +02:00
f0036bfd28 Removed SDK/buildtools workaround 2023-06-23 09:33:04 +02:00
688861bf65 Code cleanup 2023-06-23 09:30:44 +02:00
5 changed files with 27 additions and 21 deletions

View File

@ -18,9 +18,8 @@ OnlineMap::OnlineMap(const QString &fileName, const QString &name,
{
_tileLoader = new TileLoader(QDir(ProgramPaths::tilesDir()).filePath(_name),
this);
_tileLoader->setUrl(url);
_tileLoader->setUrl(url, quadTiles ? TileLoader::QuadTiles : TileLoader::XYZ);
_tileLoader->setHeaders(headers);
_tileLoader->setQuadTiles(quadTiles);
connect(_tileLoader, &TileLoader::finished, this, &OnlineMap::tilesLoaded);
}

View File

@ -52,7 +52,7 @@ static QString quadKey(const QPoint &xy, int zoom)
}
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))
qWarning("%s: %s", qPrintable(_dir), "Error creating tiles directory");
@ -176,19 +176,21 @@ QUrl TileLoader::tileUrl(const FetchTile &tile) const
{
QString url(_url);
if (!tile.bbox().isNull()) {
QString bbox = QString("%1,%2,%3,%4").arg(
QString::number(tile.bbox().left(), 'f', 6),
QString::number(tile.bbox().bottom(), 'f', 6),
QString::number(tile.bbox().right(), 'f', 6),
QString::number(tile.bbox().top(), 'f', 6));
url.replace("$bbox", bbox);
} else if (_quadTiles) {
url.replace("$quadkey", quadKey(tile.xy(), tile.zoom().toInt()));
} else {
url.replace("$z", tile.zoom().toString());
url.replace("$x", QString::number(tile.xy().x()));
url.replace("$y", QString::number(tile.xy().y()));
switch (_urlType) {
case BoundingBox:
url.replace("$bbox", QString("%1,%2,%3,%4").arg(
QString::number(tile.bbox().left(), 'f', 6),
QString::number(tile.bbox().bottom(), 'f', 6),
QString::number(tile.bbox().right(), 'f', 6),
QString::number(tile.bbox().top(), 'f', 6)));
break;
case QuadTiles:
url.replace("$quadkey", quadKey(tile.xy(), tile.zoom().toInt()));
break;
default:
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);

View File

@ -11,12 +11,17 @@ class TileLoader : public QObject
Q_OBJECT
public:
enum UrlType {
XYZ,
QuadTiles,
BoundingBox
};
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 setScaledSize(int size);
void setQuadTiles(bool quadTiles) {_quadTiles = quadTiles;}
void loadTilesAsync(QVector<FetchTile> &list);
void loadTilesSync(QVector<FetchTile> &list);
@ -31,10 +36,10 @@ private:
Downloader *_downloader;
QString _url;
UrlType _urlType;
QString _dir;
QList<HTTPHeader> _headers;
int _scaledSize;
bool _quadTiles;
};
#endif // TILELOADER_H

View File

@ -85,7 +85,7 @@ WMSMap::WMSMap(const QString &fileName, const QString &name,
void WMSMap::init()
{
_tileLoader->setUrl(tileUrl());
_tileLoader->setUrl(tileUrl(), TileLoader::BoundingBox);
_bounds = RectD(_wms->bbox(), _wms->projection());
computeZooms();
updateTransform();

View File

@ -31,7 +31,7 @@ WMTSMap::WMTSMap(const QString &fileName, const QString &name,
void WMTSMap::init()
{
_tileLoader->setUrl(_wmts->tileUrl());
_tileLoader->setUrl(_wmts->tileUrl(), TileLoader::XYZ);
_bounds = RectD(_wmts->bbox(), _wmts->projection());
updateTransform();
}