Code cleanup
[GPXSee.git] / src / map / wms.h
blobdc26a0748075ead00c3ffccbad0c453b8ac04683
1 #ifndef WMS_H
2 #define WMS_H
4 #include <QString>
5 #include <QRectF>
6 #include "common/range.h"
7 #include "common/rectc.h"
8 #include "projection.h"
9 #include "downloader.h"
10 #include "coordinatesystem.h"
12 class QXmlStreamReader;
14 class WMS
16 public:
17 class Setup
19 public:
20 Setup(const QString &url, const QString &layer, const QString &style,
21 const QString &format, const QString &crs,
22 const CoordinateSystem &cs,
23 const QList<QPair<QString, QString> > &dimensions,
24 const Authorization &authorization = Authorization())
25 : _url(url), _layer(layer), _style(style), _format(format),
26 _crs(crs), _cs(cs), _dimensions(dimensions),
27 _authorization(authorization) {}
29 const QString &url() const {return _url;}
30 const Authorization &authorization() const {return _authorization;}
31 const QString &layer() const {return _layer;}
32 const QString &style() const {return _style;}
33 const QString &format() const {return _format;}
34 const QString &crs() const {return _crs;}
35 const CoordinateSystem &coordinateSystem() const {return _cs;}
36 const QList<QPair<QString, QString> > &dimensions() const
37 {return _dimensions;}
39 private:
40 QString _url;
41 QString _layer;
42 QString _style;
43 QString _format;
44 QString _crs;
45 CoordinateSystem _cs;
46 QList<QPair<QString, QString> > _dimensions;
47 Authorization _authorization;
51 WMS(const QString &path, const Setup &setup);
53 const Projection &projection() const {return _projection;}
54 const RangeF &scaleDenominator() const {return _scaleDenominator;}
55 const RectC &boundingBox() const {return _boundingBox;}
56 const QString &version() const {return _version;}
58 bool isValid() const {return _valid;}
59 const QString &errorString() const {return _errorString;}
61 private:
62 struct Layer {
63 QString name;
64 QString style;
65 RangeF scaleDenominator;
66 RectC boundingBox;
67 bool isDefined;
68 bool hasStyle;
69 bool hasCRS;
71 Layer(const QString &name, const QString &style = QString())
72 : name(name), style(style), isDefined(false), hasStyle(false),
73 hasCRS(false) {}
74 bool operator==(const Layer &other) const
75 {return this->name == other.name;}
78 struct CTX {
79 const Setup &setup;
80 QList<Layer> layers;
81 bool formatSupported;
83 CTX(const Setup &setup);
86 RectC geographicBoundingBox(QXmlStreamReader &reader);
87 QString style(QXmlStreamReader &reader);
88 void getMap(QXmlStreamReader &reader, CTX &ctx);
89 void request(QXmlStreamReader &reader, CTX &ctx);
90 void layer(QXmlStreamReader &reader, CTX &ctx, const QList<QString> &pCRSs,
91 const QList<QString> &pStyles, RangeF &pScaleDenominator,
92 RectC &pBoundingBox);
93 void capability(QXmlStreamReader &reader, CTX &ctx);
94 void capabilities(QXmlStreamReader &reader, CTX &ctx);
95 bool parseCapabilities(const QString &path, const Setup &setup);
96 bool getCapabilities(const QString &url, const QString &file,
97 const Authorization &authorization);
99 Projection _projection;
100 RangeF _scaleDenominator;
101 RectC _boundingBox;
102 QString _version;
104 bool _valid;
105 QString _errorString;
107 static Downloader *_downloader;
110 #endif // WMS_H