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),
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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,16 +176,18 @@ QUrl TileLoader::tileUrl(const FetchTile &tile) const
|
||||
{
|
||||
QString url(_url);
|
||||
|
||||
if (!tile.bbox().isNull()) {
|
||||
QString bbox = QString("%1,%2,%3,%4").arg(
|
||||
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));
|
||||
url.replace("$bbox", bbox);
|
||||
} else if (_quadTiles) {
|
||||
QString::number(tile.bbox().top(), 'f', 6)));
|
||||
break;
|
||||
case QuadTiles:
|
||||
url.replace("$quadkey", quadKey(tile.xy(), tile.zoom().toInt()));
|
||||
} else {
|
||||
break;
|
||||
default:
|
||||
url.replace("$z", tile.zoom().toString());
|
||||
url.replace("$x", QString::number(tile.xy().x()));
|
||||
url.replace("$y", QString::number(tile.xy().y()));
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user