2018-02-20 23:37:19 +01:00
|
|
|
#ifndef WMTS_H
|
|
|
|
#define WMTS_H
|
|
|
|
|
|
|
|
#include <QSize>
|
2018-02-24 16:48:38 +01:00
|
|
|
#include <QRect>
|
2018-02-24 16:44:30 +01:00
|
|
|
#include <QSet>
|
2018-02-24 10:34:27 +01:00
|
|
|
#include <QList>
|
2018-02-24 16:44:30 +01:00
|
|
|
#include <QHash>
|
|
|
|
#include "common/rectc.h"
|
2018-02-20 23:37:19 +01:00
|
|
|
#include "projection.h"
|
|
|
|
|
|
|
|
class QXmlStreamReader;
|
|
|
|
class Downloader;
|
|
|
|
|
|
|
|
class WMTS
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct Zoom {
|
2018-02-24 10:34:27 +01:00
|
|
|
QString id;
|
2018-02-20 23:37:19 +01:00
|
|
|
qreal scaleDenominator;
|
|
|
|
QPointF topLeft;
|
|
|
|
QSize tile;
|
|
|
|
QSize matrix;
|
2018-02-24 01:59:03 +01:00
|
|
|
QRect limits;
|
2018-02-24 10:34:27 +01:00
|
|
|
|
2018-02-24 16:44:30 +01:00
|
|
|
Zoom() {}
|
|
|
|
Zoom(const QString &id, qreal scaleDenominator, const QPointF &topLeft,
|
|
|
|
const QSize &tile, const QSize &matrix, const QRect &limits) :
|
|
|
|
id(id), scaleDenominator(scaleDenominator), topLeft(topLeft),
|
|
|
|
tile(tile), matrix(matrix), limits(limits) {}
|
2018-02-24 10:34:27 +01:00
|
|
|
bool operator<(const Zoom &other) const
|
2018-02-24 16:44:30 +01:00
|
|
|
{return scaleDenominator > other.scaleDenominator;}
|
2018-02-20 23:37:19 +01:00
|
|
|
};
|
|
|
|
|
2018-02-24 01:59:03 +01:00
|
|
|
bool load(const QString &path, const QString &url, const QString &layer,
|
|
|
|
const QString &set);
|
2018-02-20 23:37:19 +01:00
|
|
|
const QString &errorString() const {return _errorString;}
|
|
|
|
|
2018-02-24 16:44:30 +01:00
|
|
|
const RectC &bounds() const {return _bounds;}
|
2018-02-24 10:34:27 +01:00
|
|
|
QList<Zoom> zooms() const;
|
2018-02-24 01:59:03 +01:00
|
|
|
const Projection &projection() const {return _projection;}
|
2018-02-20 23:37:19 +01:00
|
|
|
|
|
|
|
static Downloader *downloader() {return _downloader;}
|
|
|
|
static void setDownloader(Downloader *downloader)
|
|
|
|
{_downloader = downloader;}
|
|
|
|
|
|
|
|
private:
|
2018-02-24 16:44:30 +01:00
|
|
|
struct TileMatrix {
|
|
|
|
QString id;
|
|
|
|
qreal scaleDenominator;
|
|
|
|
QPointF topLeft;
|
|
|
|
QSize tile;
|
|
|
|
QSize matrix;
|
|
|
|
|
|
|
|
TileMatrix() : scaleDenominator(0) {}
|
|
|
|
bool operator==(const TileMatrix &other) const
|
|
|
|
{return this->id == other.id;}
|
|
|
|
bool isValid() const
|
|
|
|
{return !id.isEmpty() && scaleDenominator > 0 && tile.isValid()
|
|
|
|
&& matrix.isValid();}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MatrixLimits {
|
|
|
|
QString id;
|
|
|
|
QRect rect;
|
|
|
|
|
|
|
|
MatrixLimits() {}
|
|
|
|
MatrixLimits(const QString &id) : id(id) {}
|
|
|
|
bool operator==(const MatrixLimits &other) const
|
|
|
|
{return this->id == other.id;}
|
|
|
|
bool isValid() const
|
|
|
|
{return !id.isEmpty() && rect.isValid();}
|
|
|
|
};
|
|
|
|
|
2018-02-20 23:37:19 +01:00
|
|
|
bool createProjection(const QString &crs);
|
|
|
|
|
2018-02-24 16:44:30 +01:00
|
|
|
RectC wgs84BoundingBox(QXmlStreamReader &reader);
|
|
|
|
MatrixLimits tileMatrixLimits(QXmlStreamReader &reader);
|
|
|
|
TileMatrix tileMatrix(QXmlStreamReader &reader);
|
|
|
|
QSet<MatrixLimits> tileMatrixSetLimits(QXmlStreamReader &reader);
|
2018-02-20 23:37:19 +01:00
|
|
|
void tileMatrixSet(QXmlStreamReader &reader, const QString &set);
|
2018-02-24 01:59:03 +01:00
|
|
|
void tileMatrixSetLink(QXmlStreamReader &reader, const QString &set);
|
|
|
|
void layer(QXmlStreamReader &reader, const QString &layer,
|
|
|
|
const QString &set);
|
|
|
|
void contents(QXmlStreamReader &reader, const QString &layer,
|
|
|
|
const QString &set);
|
|
|
|
void capabilities(QXmlStreamReader &reader, const QString &layer,
|
|
|
|
const QString &set);
|
|
|
|
bool parseCapabilities(const QString &path, const QString &layer,
|
|
|
|
const QString &set);
|
2018-02-20 23:37:19 +01:00
|
|
|
bool getCapabilities(const QString &url, const QString &file);
|
|
|
|
|
2018-02-24 16:44:30 +01:00
|
|
|
QSet<TileMatrix> _matrixes;
|
|
|
|
QSet<MatrixLimits> _limits;
|
|
|
|
RectC _bounds;
|
2018-02-20 23:37:19 +01:00
|
|
|
Projection _projection;
|
|
|
|
|
|
|
|
QString _errorString;
|
|
|
|
|
|
|
|
static Downloader *_downloader;
|
2018-02-24 16:44:30 +01:00
|
|
|
|
|
|
|
friend uint qHash(const WMTS::TileMatrix &key);
|
|
|
|
friend uint qHash(const WMTS::MatrixLimits &key);
|
2018-02-20 23:37:19 +01:00
|
|
|
};
|
|
|
|
|
2018-02-24 16:44:30 +01:00
|
|
|
inline uint qHash(const WMTS::TileMatrix &key)
|
|
|
|
{
|
|
|
|
return ::qHash(key.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline uint qHash(const WMTS::MatrixLimits &key)
|
|
|
|
{
|
|
|
|
return ::qHash(key.id);
|
|
|
|
}
|
|
|
|
|
2018-02-24 01:59:03 +01:00
|
|
|
#ifndef QT_NO_DEBUG
|
|
|
|
QDebug operator<<(QDebug dbg, const WMTS::Zoom &zoom);
|
|
|
|
#endif // QT_NO_DEBUG
|
|
|
|
|
2018-02-20 23:37:19 +01:00
|
|
|
#endif // WMTS_H
|