QGIS API Documentation  3.20.0-Odense (decaadbb31)
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 
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 
288  QList<QgsGeoNodeRequest::ServiceLayerDetail> parseLayers( const QByteArray &layerResponse );
289  QgsGeoNodeStyle retrieveStyle( const QString &styleUrl );
290 
291  QNetworkReply *requestUrl( const QString &url );
292 
293 };
294 
295 #endif // QGSGEONODEREQUEST_H
Request handler for GeoNode servers.
void layersFetched(const QList< QgsGeoNodeRequest::ServiceLayerDetail > &layers)
Emitted when the result of a fetchLayers call has been received and processed.
void requestFinished()
Emitted when the existing request has been completed.
QString lastError() const
Returns the most recent error string for any encountered errors, or an empty string if no errors have...
BackendServer
GeoNode backend server type.
void statusChanged(const QString &statusQString)
Emitted when the status of an ongoing request is changed.
QByteArray lastResponse() const
Returns the most recent response obtained from the server.
QMap< QString, QString > QgsStringMap
Definition: qgis.h:1041
Service layer details for an individual layer from a GeoNode connection.
QString xyzURL
XYZ tileserver URL for layer.
QUuid uuid
Unique identifier (generate on the client side, not at the GeoNode server)
Encapsulates information about a GeoNode layer style.
QString id
Unique style ID.
QString styleUrl
Associated URL.
QDomDocument body
DOM documenting containing style.
QString name
Style name.
QString title
Style title.