QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsgeonoderequest.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgeonoderequest.h
3  ---------------------
4  begin : Jul 2017
5  copyright : (C) 2017 by Muhammad Yarjuna Rohmat, Ismail Sunni
6  email : rohmat at kartoza dot com, ismail at kartoza dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSGEONODEREQUEST_H
16 #define QGSGEONODEREQUEST_H
17 
18 #include "qgis.h"
19 #include "qgis_core.h"
20 #include <QNetworkReply>
21 #include <QDomDocument>
22 #include <QObject>
23 #include <QUuid>
24 
31 struct CORE_EXPORT QgsGeoNodeStyle
32 {
33 #ifdef SIP_RUN
34  % TypeHeaderCode
35 #include <qgsgeonoderequest.h>
36  % End
37 #endif
38 
40  QString id;
41 
43  QString name;
44 
46  QString title;
47 
49  QDomDocument body;
50 
52  QString styleUrl;
53 };
54 
65 class CORE_EXPORT QgsGeoNodeRequest : public QObject
66 {
67  Q_OBJECT
68  public:
69 
73  enum class BackendServer
74  {
75  Unknown,
76  QgisServer,
77  Geoserver
78  };
79 
84  {
86  QUuid uuid;
88  QString id;
90  QString name;
92  QString typeName;
94  QString title;
96  QString wmsURL;
98  QString wfsURL;
100  QString wcsURL;
102  QString xyzURL;
104  BackendServer server{};
105  };
106 
112  QgsGeoNodeRequest( const QString &baseUrl, bool forceRefresh, QObject *parent = nullptr );
113 
114  ~QgsGeoNodeRequest() override;
115 
128  void request( const QString &endPoint );
129 
139  bool requestBlocking( const QString &endPoint );
140 
155  void fetchLayers();
156 
165  QList<QgsGeoNodeRequest::ServiceLayerDetail> fetchLayersBlocking();
166 
175  QList<QgsGeoNodeStyle> fetchStylesBlocking( const QString &layerName );
176 
183  QgsGeoNodeStyle fetchDefaultStyleBlocking( const QString &layerName );
184 
191  QgsGeoNodeStyle fetchStyleBlocking( const QString &styleId );
192 
199  QStringList fetchServiceUrlsBlocking( const QString &serviceType );
200 
207  QgsStringMap fetchServiceUrlDataBlocking( const QString &serviceType );
208 
213  QString lastError() const { return mError; }
214 
218  QByteArray lastResponse() const { return mHttpGeoNodeResponse; }
219 
224  QString protocol() const;
225 
230  void setProtocol( const QString &protocol );
231 
235  QgsGeoNodeRequest::ServiceLayerDetail parseOwsUrl( QgsGeoNodeRequest::ServiceLayerDetail &layerStruct, const QVariantList &layerLinks );
236 
237  public slots:
238 
242  void abort();
243 
244  signals:
245 
249  void statusChanged( const QString &statusQString );
250 
254  void requestFinished();
255 
259  void layersFetched( const QList<QgsGeoNodeRequest::ServiceLayerDetail> &layers );
260 
261  private slots:
262  void replyFinished();
263  void replyProgress( qint64, qint64 );
264 
265  private:
266 
268  QString mProtocol;
269 
271  QString mBaseUrl;
272 
274  QNetworkReply *mGeoNodeReply = nullptr;
275 
277  QString mError;
278 
280  QString mErrorFormat;
281 
283  QByteArray mHttpGeoNodeResponse;
284 
285  bool mIsAborted = false;
286  bool mForceRefresh = false;
287  bool mParsingLayers = false;
288 
289  QList<QgsGeoNodeRequest::ServiceLayerDetail> parseLayers( const QByteArray &layerResponse );
290  QgsGeoNodeStyle retrieveStyle( const QString &styleUrl );
291 
292  QNetworkReply *requestUrl( const QString &url );
293 
294 };
295 
296 #endif // QGSGEONODEREQUEST_H
qgsgeonoderequest.h
QgsGeoNodeRequest::ServiceLayerDetail::typeName
QString typeName
Layer type name.
Definition: qgsgeonoderequest.h:92
QgsGeoNodeRequest::ServiceLayerDetail::wmsURL
QString wmsURL
WMS URL for layer.
Definition: qgsgeonoderequest.h:96
QgsGeoNodeStyle::id
QString id
Unique style ID.
Definition: qgsgeonoderequest.h:40
QgsGeoNodeStyle
Encapsulates information about a GeoNode layer style.
Definition: qgsgeonoderequest.h:31
qgis.h
QgsGeoNodeStyle::name
QString name
Style name.
Definition: qgsgeonoderequest.h:43
QgsGeoNodeRequest::lastResponse
QByteArray lastResponse() const
Returns the most recent response obtained from the server.
Definition: qgsgeonoderequest.h:218
QgsGeoNodeStyle::title
QString title
Style title.
Definition: qgsgeonoderequest.h:46
QgsGeoNodeRequest::BackendServer
BackendServer
GeoNode backend server type.
Definition: qgsgeonoderequest.h:73
QgsGeoNodeStyle::styleUrl
QString styleUrl
Associated URL.
Definition: qgsgeonoderequest.h:52
QgsGeoNodeRequest::ServiceLayerDetail::title
QString title
Layer title.
Definition: qgsgeonoderequest.h:94
QgsGeoNodeRequest
Request handler for GeoNode servers.
Definition: qgsgeonoderequest.h:65
QgsGeoNodeRequest::ServiceLayerDetail::xyzURL
QString xyzURL
XYZ tileserver URL for layer.
Definition: qgsgeonoderequest.h:102
QgsGeoNodeRequest::ServiceLayerDetail::wfsURL
QString wfsURL
WFS URL for layer.
Definition: qgsgeonoderequest.h:98
QgsGeoNodeRequest::ServiceLayerDetail
Service layer details for an individual layer from a GeoNode connection.
Definition: qgsgeonoderequest.h:83
QgsGeoNodeRequest::ServiceLayerDetail::uuid
QUuid uuid
Unique identifier (generate on the client side, not at the GeoNode server)
Definition: qgsgeonoderequest.h:86
QgsStringMap
QMap< QString, QString > QgsStringMap
Definition: qgis.h:2781
QgsGeoNodeRequest::ServiceLayerDetail::id
QString id
Layer id.
Definition: qgsgeonoderequest.h:88
QgsGeoNodeRequest::ServiceLayerDetail::name
QString name
Layer name.
Definition: qgsgeonoderequest.h:90
QgsGeoNodeRequest::lastError
QString lastError() const
Returns the most recent error string for any encountered errors, or an empty string if no errors have...
Definition: qgsgeonoderequest.h:213
QgsGeoNodeStyle::body
QDomDocument body
DOM documenting containing style.
Definition: qgsgeonoderequest.h:49
QgsGeoNodeRequest::ServiceLayerDetail::wcsURL
QString wcsURL
WCS URL for layer.
Definition: qgsgeonoderequest.h:100