Marble

OwsServiceManager.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2023 Torsten Rahn <rahn@kde.org>
4//
5
6#ifndef OWSSERVICEMANAGER_H
7#define OWSSERVICEMANAGER_H
8
9#include <QObject>
10#include <QNetworkAccessManager>
11#include <QImage>
12#include <QDomDocument>
13
14class QNetworkReply;
15
16namespace Marble
17{
18
19enum OwsServiceType {
20 NoOwsType,
21 WmsType,
22 WmtsType,
23 WfsType,
24 WcsType
25};
26
27enum OwsCapabilitiesStatus {
28 OwsCapabilitiesNone,
29 OwsCapabilitiesSuccess,
30 OwsCapabilitiesNoOwsServer,
31 OwsCapabilitiesReplyUnreadable,
32 OwsCapabilitiesFailed
33};
34
35
36enum WmsImageStatus {
37 WmsImageNone,
38 WmsImageSuccess,
39 WmsImageFailed,
40 WmsImageFailedServerMessage
41};
42
43class OwsMappingCapabilities {
44
45public:
46 OwsMappingCapabilities();
47
48 void setVersion(const QString& version);
49 QString version() const; // "1.1.1" or "1.3.0"
50
51 void setTitle(const QString& title);
52 QString title() const;
53
54 void setAbstract(const QString& abstract);
55 QString abstract() const;
56
57 QStringList layers() const;
58
59 QString title(const QString& layer);
60 QString abstract(const QString& layer);
61 QString style(const QString& layer);
62
63 void setOwsLayerMetaInfo(const QMap<QString, QStringList>& wmsLayerMetaInfo);
64 QMap<QString, QStringList> owsLayerMetaInfo() const;
65
66protected:
67 QString m_version;
68 QString m_title;
69 QString m_abstract;
70
71 QMap<QString, QStringList> m_owsLayerMetaInfo; // layerName -> Title, Abstract, LegendUrl, Style
72};
73
74class WmsCapabilities : public OwsMappingCapabilities {
75
76public:
77 WmsCapabilities();
78
79
80 void setContactInformation(const QString& info);
81 QString contactInformation() const;
82
83 void setFees(const QString& fee);
84 QString fees() const;
85
86 QStringList projections(const QString& layer);
87 QString boundingBox(const QString& layer, const QString& projection);
88 QString legendUrl(const QString& layer);
89 QStringList styles(const QStringList& layers);
90 QString boundingBoxNSEWDegrees(const QStringList& layers, const QString& projection);
91
92 void setReferenceSystemType(const QString& refSystem);
93 QString referenceSystemType() const; // SRS (1.1.1) or CRS (1.3.0)
94
95 void setWmsLayerCoordinateSystems(const QMap<QString, QMap<QString, QString>>& wmsLayerCoordinateSystems);
96 QMap<QString, QMap<QString, QString>> wmsLayerCoordinateSystems() const;
97
98 void setFormats(const QStringList& formats);
99 QStringList formats();
100
101 QString m_referenceSystemType;
102
103 QString m_contactInformation;
104 QString m_fees;
105
106 QMap<QString, QMap<QString, QString>> m_wmsLayerCoordinateSystems; // layerId -> epsg -> bbox
107
108 QStringList m_formats; // png, jpg, ...
109};
110
111class WmtsCapabilities : public OwsMappingCapabilities {
112
113public:
114 WmtsCapabilities();
115
116 void setWmtsTileMatrixSets(const QMap<QString, QStringList> & wmtsTileMatrixSets);
117 QMap<QString, QStringList> wmtsTileMatrixSets() const;
118 void setWmtsTileResource(const QMap<QString, QMap<QString, QString>> & wmtsTileResource);
119 QMap<QString, QMap<QString, QString>> wmtsTileResource() const;
120
121 QMap<QString, QStringList> m_wmtsTileMatrixSets; // layerId -> TileMatrixSets
122 QMap<QString, QMap<QString, QString>> m_wmtsTileResource; // layerId -> Format -> RessourceUrl
123};
124
125enum ImageResultType {
126 GenericImage,
127 LevelZeroTile,
128 PreviewImage,
129 LegendImage
130};
131
132class ImageRequestResult {
133
134public:
135 ImageRequestResult();
136
137 void setImageStatus(WmsImageStatus imageStatus);
138 WmsImageStatus imageStatus() const;
139
140 void setResultImage(const QImage& image);
141 QImage resultImage() const;
142
143 void setResultRaw(const QByteArray& resultRaw);
144 QByteArray resultRaw() const;
145
146 void setResultFormat(const QString& resultFormat);
147 QString resultFormat() const;
148
149 void setResultType(const ImageResultType);
150 ImageResultType resultType() const;
151
152private:
153 WmsImageStatus m_imageStatus;
154 QImage m_resultImage;
155 QByteArray m_resultRaw;
156 QString m_resultFormat;
157 ImageResultType m_resultType;
158};
159
160class OwsServiceManager : public QObject
161{
163public:
164 explicit OwsServiceManager(QObject *parent = nullptr);
165
166public Q_SLOTS:
167 void queryOwsCapabilities(const QUrl& queryUrl, const QString& serviceString = "WMS");
168 void queryWmsMap(const QUrl& url, const QString& layers, const QString& projection,
169 const QString& bbox, const QString& format, const QString& styles = QString());
170 void queryWmsLevelZeroTile(const QUrl& url, const QString &layers, const QString &projection,
171 const QString &format, const QString &styles = QString());
172 void queryWmsPreviewImage(const QUrl& url, const QString &layers, const QString &projection,
173 const QString &format, const QString &styles = QString());
174 void queryWmsLegendImage(const QUrl& url);
175
176 void queryWmtsLevelZeroTile(const QString& url, const QString& style, const QString& tileMatrixSet);
177 void queryWmtsPreviewImage(const QString& url, const QString& style, const QString& tileMatrixSet);
178 void queryWmtsTile(const QString& url, const QString& style, const QString& tileMatrixSet,
179 const QString& tileMatrix, const QString& tileRow, const QString& tileCol);
180
181 void queryXYZPreviewImage(const QString& urlString);
182 void queryXYZLevelZeroTile(const QString& urlString);
183 void queryXYZImage(const QString urlString);
184
185 void handleAuthentication(QNetworkReply *reply, QAuthenticator *authenticator);
186
187 void setCapabilitiesStatus(OwsCapabilitiesStatus capabilitiesStatus);
188 OwsCapabilitiesStatus capabilitiesStatus() const;
189
190 OwsServiceType owsServiceType();
191 WmsCapabilities wmsCapabilities();
192 WmtsCapabilities wmtsCapabilities();
193 ImageRequestResult imageRequestResult();
194
195 QImage resultImage();
196 QByteArray resultRaw();
197 QString resultFormat();
198 ImageResultType resultType();
199
201 void wmsCapabilitiesReady();
202 void wmtsCapabilitiesReady();
203 void imageRequestResultReady();
204
205private Q_SLOTS:
206 void parseOwsCapabilities(QNetworkReply* reply);
207 void parseWmsCapabilities(QNetworkReply* reply);
208 void parseWmtsCapabilities(QNetworkReply* reply);
209 void parseImageResult(QNetworkReply* reply);
210
211private:
212 QUrl m_url;
213 QDomDocument m_xml;
214 QNetworkAccessManager m_capabilitiesAccessManager;
215 QNetworkAccessManager m_imageAccessManager;
216 OwsCapabilitiesStatus m_capabilitiesStatus;
217 OwsServiceType m_owsServiceType;
218 WmsCapabilities m_wmsCapabilities;
219 WmtsCapabilities m_wmtsCapabilities;
220 ImageRequestResult m_imageRequestResult;
221};
222
223}
224
225#endif // OWSSERVICEMANAGER_H
Binds a QML item to a specific geodetic location in screen coordinates.
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:54:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.