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 <QDomDocument>
10#include <QImage>
11#include <QNetworkAccessManager>
12#include <QObject>
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
35enum WmsImageStatus {
36 WmsImageNone,
37 WmsImageSuccess,
38 WmsImageFailed,
39 WmsImageFailedServerMessage
40};
41
42class OwsMappingCapabilities
43{
44public:
45 OwsMappingCapabilities();
46
47 void setVersion(const QString &version);
48 QString version() const; // "1.1.1" or "1.3.0"
49
50 void setTitle(const QString &title);
51 QString title() const;
52
53 void setAbstract(const QString &abstract);
54 QString abstract() const;
55
56 QStringList layers() const;
57
58 QString title(const QString &layer);
59 QString abstract(const QString &layer);
60 QString style(const QString &layer);
61
62 void setOwsLayerMetaInfo(const QMap<QString, QStringList> &wmsLayerMetaInfo);
63 QMap<QString, QStringList> owsLayerMetaInfo() const;
64
65protected:
66 QString m_version;
67 QString m_title;
68 QString m_abstract;
69
70 QMap<QString, QStringList> m_owsLayerMetaInfo; // layerName -> Title, Abstract, LegendUrl, Style
71};
72
73class WmsCapabilities : public OwsMappingCapabilities
74{
75public:
76 WmsCapabilities();
77
78 void setContactInformation(const QString &info);
79 QString contactInformation() const;
80
81 void setFees(const QString &fee);
82 QString fees() const;
83
84 QStringList projections(const QString &layer);
85 QString boundingBox(const QString &layer, const QString &projection);
86 QString legendUrl(const QString &layer);
87 QStringList styles(const QStringList &layers);
88 QString boundingBoxNSEWDegrees(const QStringList &layers, const QString &projection);
89
90 void setReferenceSystemType(const QString &refSystem);
91 QString referenceSystemType() const; // SRS (1.1.1) or CRS (1.3.0)
92
93 void setWmsLayerCoordinateSystems(const QMap<QString, QMap<QString, QString>> &wmsLayerCoordinateSystems);
94 QMap<QString, QMap<QString, QString>> wmsLayerCoordinateSystems() const;
95
96 void setFormats(const QStringList &formats);
97 QStringList formats();
98
99 QString m_referenceSystemType;
100
101 QString m_contactInformation;
102 QString m_fees;
103
104 QMap<QString, QMap<QString, QString>> m_wmsLayerCoordinateSystems; // layerId -> epsg -> bbox
105
106 QStringList m_formats; // png, jpg, ...
107};
108
109class WmtsCapabilities : public OwsMappingCapabilities
110{
111public:
112 WmtsCapabilities();
113
114 void setWmtsTileMatrixSets(const QMap<QString, QStringList> &wmtsTileMatrixSets);
115 QMap<QString, QStringList> wmtsTileMatrixSets() const;
116 void setWmtsTileResource(const QMap<QString, QMap<QString, QString>> &wmtsTileResource);
117 QMap<QString, QMap<QString, QString>> wmtsTileResource() const;
118
119 QMap<QString, QStringList> m_wmtsTileMatrixSets; // layerId -> TileMatrixSets
120 QMap<QString, QMap<QString, QString>> m_wmtsTileResource; // layerId -> Format -> RessourceUrl
121};
122
123enum ImageResultType {
124 GenericImage,
125 LevelZeroTile,
126 PreviewImage,
127 LegendImage
128};
129
130class ImageRequestResult
131{
132public:
133 ImageRequestResult();
134
135 void setImageStatus(WmsImageStatus imageStatus);
136 WmsImageStatus imageStatus() const;
137
138 void setResultImage(const QImage &image);
139 QImage resultImage() const;
140
141 void setResultRaw(const QByteArray &resultRaw);
142 QByteArray resultRaw() const;
143
144 void setResultFormat(const QString &resultFormat);
145 QString resultFormat() const;
146
147 void setResultType(const ImageResultType);
148 ImageResultType resultType() const;
149
150private:
151 WmsImageStatus m_imageStatus;
152 QImage m_resultImage;
153 QByteArray m_resultRaw;
154 QString m_resultFormat;
155 ImageResultType m_resultType;
156};
157
158class OwsServiceManager : public QObject
159{
161public:
162 explicit OwsServiceManager(QObject *parent = nullptr);
163
164public Q_SLOTS:
165 void queryOwsCapabilities(const QUrl &queryUrl, const QString &serviceString = QStringLiteral("WMS"));
166 void queryWmsMap(const QUrl &url,
167 const QString &layers,
168 const QString &projection,
169 const QString &bbox,
170 const QString &format,
171 const QString &styles = QString());
172 void queryWmsLevelZeroTile(const QUrl &url, const QString &layers, const QString &projection, const QString &format, const QString &styles = QString());
173 void queryWmsPreviewImage(const QUrl &url, const QString &layers, const QString &projection, 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,
179 const QString &style,
180 const QString &tileMatrixSet,
181 const QString &tileMatrix,
182 const QString &tileRow,
183 const QString &tileCol);
184
185 void queryXYZPreviewImage(const QString &urlString);
186 void queryXYZLevelZeroTile(const QString &urlString);
187 void queryXYZImage(const QString urlString);
188
189 void handleAuthentication(QNetworkReply *reply, QAuthenticator *authenticator);
190
191 void setCapabilitiesStatus(OwsCapabilitiesStatus capabilitiesStatus);
192 OwsCapabilitiesStatus capabilitiesStatus() const;
193
194 OwsServiceType owsServiceType();
195 WmsCapabilities wmsCapabilities();
196 WmtsCapabilities wmtsCapabilities();
197 ImageRequestResult imageRequestResult();
198
199 QImage resultImage();
200 QByteArray resultRaw();
201 QString resultFormat();
202 ImageResultType resultType();
203
205 void wmsCapabilitiesReady();
206 void wmtsCapabilitiesReady();
207 void imageRequestResultReady();
208
209private Q_SLOTS:
210 void parseOwsCapabilities(QNetworkReply *reply);
211 void parseWmsCapabilities(QNetworkReply *reply);
212 void parseWmtsCapabilities(QNetworkReply *reply);
213 void parseImageResult(QNetworkReply *reply);
214
215private:
216 QUrl m_url;
217 QDomDocument m_xml;
218 QNetworkAccessManager m_capabilitiesAccessManager;
219 QNetworkAccessManager m_imageAccessManager;
220 OwsCapabilitiesStatus m_capabilitiesStatus;
221 OwsServiceType m_owsServiceType;
222 WmsCapabilities m_wmsCapabilities;
223 WmtsCapabilities m_wmtsCapabilities;
224 ImageRequestResult m_imageRequestResult;
225};
226
227}
228
229#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
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:02:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.