QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
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
qgsgeonoderequest.h
QgsGeoNodeRequest::layersFetched
void layersFetched(const QList< QgsGeoNodeRequest::ServiceLayerDetail > &layers)
Emitted when the result of a fetchLayers call has been received and processed.
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:32
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:216
QgsGeoNodeStyle::title
QString title
Style title.
Definition: qgsgeonoderequest.h:46
QgsGeoNodeRequest::statusChanged
void statusChanged(const QString &statusQString)
Emitted when the status of an ongoing request is changed.
QgsGeoNodeRequest::BackendServer
BackendServer
GeoNode backend server type.
Definition: qgsgeonoderequest.h:74
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:66
QgsGeoNodeRequest::ServiceLayerDetail::xyzURL
QString xyzURL
XYZ tileserver URL for layer.
Definition: qgsgeonoderequest.h:100
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:84
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:758
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:211
QgsGeoNodeStyle::body
QDomDocument body
DOM documenting containing style.
Definition: qgsgeonoderequest.h:49
QgsGeoNodeRequest::requestFinished
void requestFinished()
Emitted when the existing request has been completed.