QGIS API Documentation  3.12.1-BucureČ™ti (121cc00ff0)
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 xyzURL;
102  BackendServer server{};
103  };
104 
110  QgsGeoNodeRequest( const QString &baseUrl, bool forceRefresh, QObject *parent = nullptr );
111 
112  ~QgsGeoNodeRequest() override;
113 
126  void request( const QString &endPoint );
127 
137  bool requestBlocking( const QString &endPoint );
138 
153  void fetchLayers();
154 
163  QList<QgsGeoNodeRequest::ServiceLayerDetail> fetchLayersBlocking();
164 
173  QList<QgsGeoNodeStyle> fetchStylesBlocking( const QString &layerName );
174 
181  QgsGeoNodeStyle fetchDefaultStyleBlocking( const QString &layerName );
182 
189  QgsGeoNodeStyle fetchStyleBlocking( const QString &styleId );
190 
197  QStringList fetchServiceUrlsBlocking( const QString &serviceType );
198 
205  QgsStringMap fetchServiceUrlDataBlocking( const QString &serviceType );
206 
211  QString lastError() const { return mError; }
212 
216  QByteArray lastResponse() const { return mHttpGeoNodeResponse; }
217 
222  QString protocol() const;
223 
228  void setProtocol( const QString &protocol );
229 
233  QgsGeoNodeRequest::ServiceLayerDetail parseOwsUrl( QgsGeoNodeRequest::ServiceLayerDetail &layerStruct, const QVariantList &layerLinks );
234 
235  public slots:
236 
240  void abort();
241 
242  signals:
243 
247  void statusChanged( const QString &statusQString );
248 
252  void requestFinished();
253 
257  void layersFetched( const QList<QgsGeoNodeRequest::ServiceLayerDetail> &layers );
258 
259  private slots:
260  void replyFinished();
261  void replyProgress( qint64, qint64 );
262 
263  private:
264 
266  QString mProtocol;
267 
269  QString mBaseUrl;
270 
272  QNetworkReply *mGeoNodeReply = nullptr;
273 
275  QString mError;
276 
278  QString mErrorFormat;
279 
281  QByteArray mHttpGeoNodeResponse;
282 
283  bool mIsAborted = false;
284  bool mForceRefresh = false;
285 
286  QList<QgsGeoNodeRequest::ServiceLayerDetail> parseLayers( const QByteArray &layerResponse );
287  QgsGeoNodeStyle retrieveStyle( const QString &styleUrl );
288 
289  QNetworkReply *requestUrl( const QString &url );
290 
291 };
292 
293 #endif // QGSGEONODEREQUEST_H
Request handler for GeoNode servers.
Encapsulates information about a GeoNode layer style.
QString styleUrl
Associated URL.
Service layer details for an individual layer from a GeoNode connection.
QByteArray lastResponse() const
Returns the most recent response obtained from the server.
QString wmsURL
WMS URL for layer.
QMap< QString, QString > QgsStringMap
Definition: qgis.h:694
QDomDocument body
DOM documenting containing style.
BackendServer
GeoNode backend server type.
QString xyzURL
XYZ tileserver URL for layer.
QString wfsURL
WFS URL for layer.
QString id
Unique style ID.
QString lastError() const
Returns the most recent error string for any encountered errors, or an empty string if no errors have...
QString name
Style name.
QUuid uuid
Unique identifier (generate on the client side, not at the GeoNode server)
QString title
Style title.