QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsarcgisrestquery.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsarcgisrestquery.h
3  --------------------
4  begin : December 2020
5  copyright : (C) 2020 by Nyall Dawson
6  email : nyall dot dawson at gmail 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 QGSARCGISRESTQUERY_H
16 #define QGSARCGISRESTQUERY_H
17 
18 #define SIP_NO_FILE
19 
20 #include "qgis_core.h"
21 #include "qgsrectangle.h"
22 #include "qgswkbtypes.h"
23 #include "qgshttpheaders.h"
24 
25 #include <QString>
26 #include <QVariantMap>
27 
28 class QgsFeedback;
29 class QNetworkReply;
30 
37 class CORE_EXPORT QgsArcGisRestQueryUtils
38 {
39  public:
40 
45  {
48  Raster
49  };
50 
54  static QVariantMap getServiceInfo( const QString &baseurl, const QString &authcfg, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders = QgsHttpHeaders() );
55 
59  static QVariantMap getLayerInfo( const QString &layerurl, const QString &authcfg, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders = QgsHttpHeaders() );
60 
64  static QVariantMap getObjectIds( const QString &layerurl, const QString &authcfg, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders = QgsHttpHeaders(),
65  const QgsRectangle &bbox = QgsRectangle() );
66 
70  static QVariantMap getObjects( const QString &layerurl, const QString &authcfg, const QList<quint32> &objectIds, const QString &crs,
71  bool fetchGeometry, const QStringList &fetchAttributes, bool fetchM, bool fetchZ,
72  const QgsRectangle &filterRect, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders = QgsHttpHeaders(), QgsFeedback *feedback = nullptr );
73 
77  static QList<quint32> getObjectIdsByExtent( const QString &layerurl, const QgsRectangle &filterRect, QString &errorTitle, QString &errorText, const QString &authcfg, const QgsHttpHeaders &requestHeaders = QgsHttpHeaders(), QgsFeedback *feedback = nullptr );
78 
82  static QByteArray queryService( const QUrl &url, const QString &authcfg, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders = QgsHttpHeaders(), QgsFeedback *feedback = nullptr, QString *contentType = nullptr );
83 
87  static QVariantMap queryServiceJSON( const QUrl &url, const QString &authcfg, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders = QgsHttpHeaders(), QgsFeedback *feedback = nullptr );
88 
92  static void visitFolderItems( const std::function<void ( const QString &folderName, const QString &url )> &visitor, const QVariantMap &serviceData, const QString &baseUrl );
93 
97  static void visitServiceItems( const std::function<void ( const QString &serviceName, const QString &url, const QString &service, ServiceTypeFilter serviceType )> &visitor, const QVariantMap &serviceData, const QString &baseUrl );
98 
102  static void addLayerItems( const std::function<void ( const QString &parentLayerId, ServiceTypeFilter serviceType, QgsWkbTypes::GeometryType geometryType, const QString &layerId, const QString &name, const QString &description, const QString &url, bool isParentLayer, const QString &authid, const QString &format )> &visitor, const QVariantMap &serviceData, const QString &parentUrl, const QString &parentSupportedFormats, const ServiceTypeFilter filter = AllTypes );
103 
104  private:
105 
106  static QUrl parseUrl( const QUrl &url );
107  static void adjustBaseUrl( QString &baseUrl, const QString &name );
108 
109  friend class TestQgsArcGisRestUtils;
110 };
111 
113 class CORE_EXPORT QgsArcGisAsyncQuery : public QObject
114 {
115  Q_OBJECT
116  public:
117  QgsArcGisAsyncQuery( QObject *parent = nullptr );
118  ~QgsArcGisAsyncQuery() override;
119 
120  void start( const QUrl &url, const QString &authCfg, QByteArray *result, bool allowCache = false, const QgsHttpHeaders &headers = QgsHttpHeaders() );
121  signals:
122  void finished();
123  void failed( QString errorTitle, QString errorName );
124  private slots:
125  void handleReply();
126 
127  private:
128  QNetworkReply *mReply = nullptr;
129  QByteArray *mResult = nullptr;
130 };
131 
132 class CORE_EXPORT QgsArcGisAsyncParallelQuery : public QObject
133 {
134  Q_OBJECT
135  public:
136  QgsArcGisAsyncParallelQuery( const QString &authcfg, const QgsHttpHeaders &requestHeaders, QObject *parent = nullptr );
137  void start( const QVector<QUrl> &urls, QVector<QByteArray> *results, bool allowCache = false );
138 
139  signals:
140  void finished( QStringList errors );
141  private slots:
142  void handleReply();
143 
144  private:
145  QVector<QByteArray> *mResults = nullptr;
146  int mPendingRequests = 0;
147  QStringList mErrors;
148  QString mAuthCfg;
149  QgsHttpHeaders mRequestHeaders;
150 };
151 
153 
154 #endif // QGSARCGISRESTQUERY_H
qgsrectangle.h
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
qgshttpheaders.h
QgsArcGisRestQueryUtils::Vector
@ Vector
Vector type.
Definition: qgsarcgisrestquery.h:47
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
QgsArcGisRestQueryUtils::ServiceTypeFilter
ServiceTypeFilter
Service types.
Definition: qgsarcgisrestquery.h:44
QgsArcGisRestQueryUtils::AllTypes
@ AllTypes
All types.
Definition: qgsarcgisrestquery.h:46
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:140
QgsHttpHeaders
This class implements simple http header management.
Definition: qgshttpheaders.h:38
QgsArcGisRestQueryUtils
Utility functions for querying ArcGIS REST services.
Definition: qgsarcgisrestquery.h:37
qgswkbtypes.h