QGIS API Documentation 3.29.0-Master (da8bb1db43)
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
28class QgsFeedback;
29class QNetworkReply;
30
37class CORE_EXPORT QgsArcGisRestQueryUtils
38{
39 public:
40
45 {
46 AllTypes,
47 Vector,
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 const QString &whereClause = QString() );
67
68
74 static QgsRectangle getExtent( const QString &layerurl, const QString &whereClause, const QString &authcfg, const QgsHttpHeaders &requestHeaders = QgsHttpHeaders() );
75
79 static QVariantMap getObjects( const QString &layerurl, const QString &authcfg, const QList<quint32> &objectIds, const QString &crs,
80 bool fetchGeometry, const QStringList &fetchAttributes, bool fetchM, bool fetchZ,
81 const QgsRectangle &filterRect, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders = QgsHttpHeaders(), QgsFeedback *feedback = nullptr );
82
86 static QList<quint32> getObjectIdsByExtent( const QString &layerurl, const QgsRectangle &filterRect, QString &errorTitle, QString &errorText, const QString &authcfg, const QgsHttpHeaders &requestHeaders = QgsHttpHeaders(), QgsFeedback *feedback = nullptr,
87 const QString &whereClause = QString() );
88
92 static QByteArray queryService( const QUrl &url, const QString &authcfg, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders = QgsHttpHeaders(), QgsFeedback *feedback = nullptr, QString *contentType = nullptr );
93
97 static QVariantMap queryServiceJSON( const QUrl &url, const QString &authcfg, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders = QgsHttpHeaders(), QgsFeedback *feedback = nullptr );
98
102 static void visitFolderItems( const std::function<void ( const QString &folderName, const QString &url )> &visitor, const QVariantMap &serviceData, const QString &baseUrl );
103
107 static void visitServiceItems( const std::function<void ( const QString &serviceName, const QString &url, Qgis::ArcGisRestServiceType serviceType )> &visitor, const QVariantMap &serviceData, const QString &baseUrl );
108
112 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 = ServiceTypeFilter::AllTypes );
113
117 static QUrl parseUrl( const QUrl &url, bool *isTestEndpoint = nullptr );
118
119 private:
120
121 static void adjustBaseUrl( QString &baseUrl, const QString &name );
122
123 friend class TestQgsArcGisRestUtils;
124};
125
127class CORE_EXPORT QgsArcGisAsyncQuery : public QObject
128{
129 Q_OBJECT
130 public:
131 QgsArcGisAsyncQuery( QObject *parent = nullptr );
132 ~QgsArcGisAsyncQuery() override;
133
134 void start( const QUrl &url, const QString &authCfg, QByteArray *result, bool allowCache = false, const QgsHttpHeaders &headers = QgsHttpHeaders() );
135 signals:
136 void finished();
137 void failed( QString errorTitle, QString errorName );
138 private slots:
139 void handleReply();
140
141 private:
142 QNetworkReply *mReply = nullptr;
143 QByteArray *mResult = nullptr;
144};
145
146class CORE_EXPORT QgsArcGisAsyncParallelQuery : public QObject
147{
148 Q_OBJECT
149 public:
150 QgsArcGisAsyncParallelQuery( const QString &authcfg, const QgsHttpHeaders &requestHeaders, QObject *parent = nullptr );
151 void start( const QVector<QUrl> &urls, QVector<QByteArray> *results, bool allowCache = false );
152
153 signals:
154 void finished( QStringList errors );
155 private slots:
156 void handleReply();
157
158 private:
159 QVector<QByteArray> *mResults = nullptr;
160 int mPendingRequests = 0;
161 QStringList mErrors;
162 QString mAuthCfg;
163 QgsHttpHeaders mRequestHeaders;
164};
165
167
168#endif // QGSARCGISRESTQUERY_H
ArcGisRestServiceType
Available ArcGIS REST service types.
Definition: qgis.h:2445
Utility functions for querying ArcGIS REST services.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
This class implements simple http header management.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:141
const QgsCoordinateReferenceSystem & crs