1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-06 23:03:22 +02:00
GPXSee/src/map/wmts.h

121 lines
3.1 KiB
C
Raw Normal View History

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>
#include <QSet>
#include <QList>
#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 {
QString id;
2018-02-20 23:37:19 +01:00
qreal scaleDenominator;
QPointF topLeft;
QSize tile;
QSize matrix;
QRect limits;
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) {}
bool operator<(const Zoom &other) const
{return scaleDenominator > other.scaleDenominator;}
2018-02-20 23:37:19 +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;}
const RectC &bounds() const {return _bounds;}
QList<Zoom> zooms() const;
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:
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);
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);
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);
QSet<TileMatrix> _matrixes;
QSet<MatrixLimits> _limits;
RectC _bounds;
2018-02-20 23:37:19 +01:00
Projection _projection;
QString _errorString;
static Downloader *_downloader;
friend uint qHash(const WMTS::TileMatrix &key);
friend uint qHash(const WMTS::MatrixLimits &key);
2018-02-20 23:37:19 +01:00
};
inline uint qHash(const WMTS::TileMatrix &key)
{
return ::qHash(key.id);
}
inline uint qHash(const WMTS::MatrixLimits &key)
{
return ::qHash(key.id);
}
#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