2018-02-20 23:37:19 +01:00
|
|
|
#ifndef TILELOADER_H
|
|
|
|
#define TILELOADER_H
|
|
|
|
|
2018-04-27 19:31:27 +02:00
|
|
|
#include <QObject>
|
2018-02-20 23:37:19 +01:00
|
|
|
#include <QString>
|
2021-08-26 22:22:18 +02:00
|
|
|
#include "common/downloader.h"
|
2023-12-11 18:54:46 +01:00
|
|
|
#include "rectd.h"
|
2018-02-20 23:37:19 +01:00
|
|
|
|
2018-04-27 19:31:27 +02:00
|
|
|
class TileLoader : public QObject
|
2018-02-20 23:37:19 +01:00
|
|
|
{
|
2018-04-27 19:31:27 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2018-02-20 23:37:19 +01:00
|
|
|
public:
|
2023-06-23 09:30:44 +02:00
|
|
|
enum UrlType {
|
|
|
|
XYZ,
|
|
|
|
QuadTiles,
|
|
|
|
BoundingBox
|
|
|
|
};
|
|
|
|
|
2023-12-11 18:54:46 +01:00
|
|
|
class Tile
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Tile() {}
|
|
|
|
Tile(const QPoint &xy, int zoom)
|
|
|
|
: _xy(xy), _zoom(zoom) {}
|
|
|
|
Tile(const QPoint &xy, const QString &zoom)
|
|
|
|
: _xy(xy), _zoom(zoom) {}
|
|
|
|
Tile(const QPoint &xy, int zoom, const RectD &bbox)
|
|
|
|
: _xy(xy), _zoom(zoom), _bbox(bbox) {}
|
|
|
|
|
|
|
|
const QVariant &zoom() const {return _zoom;}
|
|
|
|
const QPoint &xy() const {return _xy;}
|
|
|
|
const RectD &bbox() const {return _bbox;}
|
|
|
|
const QString &file() const {return _file;}
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class TileLoader;
|
|
|
|
|
|
|
|
void setFile(const QString &file) {_file = file;}
|
|
|
|
|
|
|
|
QPoint _xy;
|
|
|
|
QVariant _zoom;
|
|
|
|
RectD _bbox;
|
|
|
|
QString _file;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-09-24 22:49:10 +02:00
|
|
|
TileLoader(const QString &dir, QObject *parent = 0);
|
2018-04-27 19:31:27 +02:00
|
|
|
|
2023-06-23 09:30:44 +02:00
|
|
|
void setUrl(const QString &url, UrlType type) {_url = url; _urlType = type;}
|
2023-05-13 15:01:35 +02:00
|
|
|
void setHeaders(const QList<HTTPHeader> &headers) {_headers = headers;}
|
2018-02-20 23:37:19 +01:00
|
|
|
|
2023-12-11 18:54:46 +01:00
|
|
|
void loadTilesAsync(QVector<Tile> &list);
|
|
|
|
void loadTilesSync(QVector<Tile> &list);
|
2018-02-20 23:37:19 +01:00
|
|
|
void clearCache();
|
|
|
|
|
2018-04-27 19:31:27 +02:00
|
|
|
signals:
|
|
|
|
void finished();
|
2018-02-20 23:37:19 +01:00
|
|
|
|
|
|
|
private:
|
2023-12-11 18:54:46 +01:00
|
|
|
QUrl tileUrl(const Tile &tile) const;
|
|
|
|
QString tileFile(const Tile &tile) const;
|
2018-02-20 23:37:19 +01:00
|
|
|
|
2018-04-27 19:31:27 +02:00
|
|
|
Downloader *_downloader;
|
2018-02-20 23:37:19 +01:00
|
|
|
QString _url;
|
2023-06-23 09:30:44 +02:00
|
|
|
UrlType _urlType;
|
2018-02-20 23:37:19 +01:00
|
|
|
QString _dir;
|
2023-05-13 15:01:35 +02:00
|
|
|
QList<HTTPHeader> _headers;
|
2018-02-20 23:37:19 +01:00
|
|
|
};
|
|
|
|
|
2021-08-26 22:22:18 +02:00
|
|
|
#endif // TILELOADER_H
|