1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-12-05 00:39:09 +01:00

Compare commits

..

No commits in common. "1dc963b133576df2aaca35e46974ba1dd874fb4a" and "c449024584cc5928ed7c108ac186463bf5e11477" have entirely different histories.

5 changed files with 21 additions and 27 deletions

View File

@ -18,8 +18,9 @@ OnlineMap::OnlineMap(const QString &fileName, const QString &name,
{
_tileLoader = new TileLoader(QDir(ProgramPaths::tilesDir()).filePath(_name),
this);
_tileLoader->setUrl(url, quadTiles ? TileLoader::QuadTiles : TileLoader::XYZ);
_tileLoader->setUrl(url);
_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), _urlType(XYZ), _dir(dir), _scaledSize(0)
: QObject(parent), _dir(dir), _scaledSize(0), _quadTiles(false)
{
if (!QDir().mkpath(_dir))
qWarning("%s: %s", qPrintable(_dir), "Error creating tiles directory");
@ -176,21 +176,19 @@ QUrl TileLoader::tileUrl(const FetchTile &tile) const
{
QString url(_url);
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()));
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()));
}
return QUrl(url);

View File

@ -11,17 +11,12 @@ class TileLoader : public QObject
Q_OBJECT
public:
enum UrlType {
XYZ,
QuadTiles,
BoundingBox
};
TileLoader(const QString &dir, QObject *parent = 0);
void setUrl(const QString &url, UrlType type) {_url = url; _urlType = type;}
void setUrl(const QString &url) {_url = url;}
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);
@ -36,10 +31,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::BoundingBox);
_tileLoader->setUrl(tileUrl());
_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::XYZ);
_tileLoader->setUrl(_wmts->tileUrl());
_bounds = RectD(_wmts->bbox(), _wmts->projection());
updateTransform();
}