2018-03-30 10:25:05 +02:00
|
|
|
#ifndef WMS_H
|
|
|
|
#define WMS_H
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QRectF>
|
|
|
|
#include "common/range.h"
|
2018-04-01 20:01:25 +02:00
|
|
|
#include "common/rectc.h"
|
2018-09-30 12:16:41 +02:00
|
|
|
#include "common/kv.h"
|
2021-08-26 22:22:18 +02:00
|
|
|
#include "common/downloader.h"
|
2018-03-30 10:25:05 +02:00
|
|
|
#include "projection.h"
|
2018-04-05 21:13:48 +02:00
|
|
|
#include "coordinatesystem.h"
|
2018-03-30 10:25:05 +02:00
|
|
|
|
|
|
|
class QXmlStreamReader;
|
|
|
|
|
2020-03-17 21:06:51 +01:00
|
|
|
class WMS : public QObject
|
2018-03-30 10:25:05 +02:00
|
|
|
{
|
2020-03-17 21:06:51 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
2018-03-30 10:25:05 +02:00
|
|
|
public:
|
|
|
|
class Setup
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Setup(const QString &url, const QString &layer, const QString &style,
|
2018-09-30 12:16:41 +02:00
|
|
|
const QString &format, const QString &crs, const CoordinateSystem &cs,
|
2019-08-01 08:36:58 +02:00
|
|
|
const QList<KV<QString, QString> > &dimensions,
|
2018-04-08 19:13:16 +02:00
|
|
|
const Authorization &authorization = Authorization())
|
2018-04-07 18:42:25 +02:00
|
|
|
: _url(url), _layer(layer), _style(style), _format(format),
|
2018-04-08 19:13:16 +02:00
|
|
|
_crs(crs), _cs(cs), _dimensions(dimensions),
|
|
|
|
_authorization(authorization) {}
|
2018-03-30 10:25:05 +02:00
|
|
|
|
|
|
|
const QString &url() const {return _url;}
|
2018-04-01 20:01:25 +02:00
|
|
|
const Authorization &authorization() const {return _authorization;}
|
2018-03-30 10:25:05 +02:00
|
|
|
const QString &layer() const {return _layer;}
|
|
|
|
const QString &style() const {return _style;}
|
|
|
|
const QString &format() const {return _format;}
|
|
|
|
const QString &crs() const {return _crs;}
|
2018-04-07 18:42:25 +02:00
|
|
|
const CoordinateSystem &coordinateSystem() const {return _cs;}
|
2019-08-01 08:36:58 +02:00
|
|
|
const QList<KV<QString, QString> > &dimensions() const
|
|
|
|
{return _dimensions;}
|
2018-03-30 10:25:05 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
QString _url;
|
|
|
|
QString _layer;
|
|
|
|
QString _style;
|
|
|
|
QString _format;
|
|
|
|
QString _crs;
|
2018-04-07 18:42:25 +02:00
|
|
|
CoordinateSystem _cs;
|
2019-08-01 08:36:58 +02:00
|
|
|
QList<KV<QString, QString> > _dimensions;
|
2018-04-01 20:01:25 +02:00
|
|
|
Authorization _authorization;
|
2018-03-30 10:25:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-03-17 21:06:51 +01:00
|
|
|
WMS(const QString &path, const Setup &setup, QObject *parent = 0);
|
2018-03-30 10:25:05 +02:00
|
|
|
|
2020-03-17 21:06:51 +01:00
|
|
|
const RectC &bbox() const {return _bbox;}
|
2018-03-30 10:25:05 +02:00
|
|
|
const Projection &projection() const {return _projection;}
|
2020-03-17 21:06:51 +01:00
|
|
|
CoordinateSystem cs() const {return _cs;}
|
2018-03-30 10:25:05 +02:00
|
|
|
const RangeF &scaleDenominator() const {return _scaleDenominator;}
|
2018-03-31 11:27:01 +02:00
|
|
|
const QString &version() const {return _version;}
|
2020-03-17 21:06:51 +01:00
|
|
|
const QString &getMapUrl() const {return _getMapUrl;}
|
|
|
|
const WMS::Setup &setup() const {return _setup;}
|
2018-03-30 10:25:05 +02:00
|
|
|
|
2020-03-17 21:06:51 +01:00
|
|
|
bool isReady() const {return _valid && _ready;}
|
2018-03-30 10:25:05 +02:00
|
|
|
bool isValid() const {return _valid;}
|
|
|
|
const QString &errorString() const {return _errorString;}
|
|
|
|
|
2020-03-17 21:06:51 +01:00
|
|
|
signals:
|
|
|
|
void downloadFinished();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void capabilitiesReady();
|
|
|
|
|
2018-03-30 10:25:05 +02:00
|
|
|
private:
|
2018-04-02 19:59:52 +02:00
|
|
|
struct Layer {
|
|
|
|
QString name;
|
|
|
|
QString style;
|
2018-03-30 10:25:05 +02:00
|
|
|
RangeF scaleDenominator;
|
2018-04-01 20:01:25 +02:00
|
|
|
RectC boundingBox;
|
2018-04-02 19:59:52 +02:00
|
|
|
bool isDefined;
|
|
|
|
bool hasStyle;
|
|
|
|
bool hasCRS;
|
|
|
|
|
2018-04-03 22:35:13 +02:00
|
|
|
Layer(const QString &name, const QString &style = QString())
|
2018-04-02 19:59:52 +02:00
|
|
|
: name(name), style(style), isDefined(false), hasStyle(false),
|
|
|
|
hasCRS(false) {}
|
|
|
|
bool operator==(const Layer &other) const
|
|
|
|
{return this->name == other.name;}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CTX {
|
|
|
|
const Setup &setup;
|
|
|
|
QList<Layer> layers;
|
|
|
|
bool formatSupported;
|
2020-03-04 19:47:23 +01:00
|
|
|
QString url;
|
2018-03-30 10:25:05 +02:00
|
|
|
|
2018-04-02 19:59:52 +02:00
|
|
|
CTX(const Setup &setup);
|
2018-03-30 10:25:05 +02:00
|
|
|
};
|
|
|
|
|
2018-04-01 20:01:25 +02:00
|
|
|
RectC geographicBoundingBox(QXmlStreamReader &reader);
|
2018-03-30 10:25:05 +02:00
|
|
|
QString style(QXmlStreamReader &reader);
|
2020-03-04 19:47:23 +01:00
|
|
|
void get(QXmlStreamReader &reader, CTX &ctx);
|
|
|
|
void http(QXmlStreamReader &reader, CTX &ctx);
|
|
|
|
void dcpType(QXmlStreamReader &reader, CTX &ctx);
|
2018-03-30 10:25:05 +02:00
|
|
|
void getMap(QXmlStreamReader &reader, CTX &ctx);
|
|
|
|
void request(QXmlStreamReader &reader, CTX &ctx);
|
|
|
|
void layer(QXmlStreamReader &reader, CTX &ctx, const QList<QString> &pCRSs,
|
2018-04-01 20:01:25 +02:00
|
|
|
const QList<QString> &pStyles, RangeF &pScaleDenominator,
|
|
|
|
RectC &pBoundingBox);
|
2018-03-30 10:25:05 +02:00
|
|
|
void capability(QXmlStreamReader &reader, CTX &ctx);
|
|
|
|
void capabilities(QXmlStreamReader &reader, CTX &ctx);
|
2020-03-17 21:06:51 +01:00
|
|
|
bool parseCapabilities();
|
2018-03-30 10:25:05 +02:00
|
|
|
|
2020-03-17 21:06:51 +01:00
|
|
|
WMS::Setup _setup;
|
|
|
|
QString _path;
|
2018-03-30 10:25:05 +02:00
|
|
|
Projection _projection;
|
|
|
|
RangeF _scaleDenominator;
|
2020-03-17 21:06:51 +01:00
|
|
|
RectC _bbox;
|
2018-03-31 11:27:01 +02:00
|
|
|
QString _version;
|
2020-03-17 21:06:51 +01:00
|
|
|
QString _getMapUrl;
|
|
|
|
CoordinateSystem _cs;
|
2018-03-30 10:25:05 +02:00
|
|
|
|
2020-03-17 21:06:51 +01:00
|
|
|
bool _valid, _ready;
|
2018-03-30 10:25:05 +02:00
|
|
|
QString _errorString;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // WMS_H
|