17#include "moc_qgsarcgisrestquery.cpp"
30#include <QImageReader>
31#include <QRegularExpression>
32#include <QJsonParseError>
37 QUrl queryUrl( baseurl );
38 QUrlQuery query( queryUrl );
39 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"json" ) );
40 queryUrl.setQuery( query );
41 return queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders,
nullptr, urlPrefix );
47 QUrl queryUrl( layerurl );
48 QUrlQuery query( queryUrl );
49 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"json" ) );
50 queryUrl.setQuery( query );
51 return queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders,
nullptr, urlPrefix );
57 QUrl queryUrl( layerurl +
"/query" );
58 QUrlQuery query( queryUrl );
59 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"json" ) );
60 query.addQueryItem( QStringLiteral(
"where" ), whereClause.isEmpty() ? QStringLiteral(
"1=1" ) : whereClause );
61 query.addQueryItem( QStringLiteral(
"returnIdsOnly" ), QStringLiteral(
"true" ) );
64 query.addQueryItem( QStringLiteral(
"geometry" ), QStringLiteral(
"%1,%2,%3,%4" )
67 query.addQueryItem( QStringLiteral(
"geometryType" ), QStringLiteral(
"esriGeometryEnvelope" ) );
68 query.addQueryItem( QStringLiteral(
"spatialRel" ), QStringLiteral(
"esriSpatialRelEnvelopeIntersects" ) );
70 queryUrl.setQuery( query );
71 return queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders,
nullptr, urlPrefix );
77 QUrl queryUrl( layerurl +
"/query" );
78 QUrlQuery query( queryUrl );
79 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"json" ) );
80 query.addQueryItem( QStringLiteral(
"where" ), whereClause );
81 query.addQueryItem( QStringLiteral(
"returnExtentOnly" ), QStringLiteral(
"true" ) );
82 queryUrl.setQuery( query );
85 const QVariantMap res =
queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders,
nullptr, urlPrefix );
88 QgsDebugError( QStringLiteral(
"getExtent failed: %1 - %2" ).arg( errorTitle, errorText ) );
96 bool fetchGeometry,
const QStringList &fetchAttributes,
97 bool fetchM,
bool fetchZ,
99 QString &errorTitle, QString &errorText,
const QgsHttpHeaders &requestHeaders,
QgsFeedback *feedback,
const QString &urlPrefix )
102 for (
const int id : objectIds )
104 ids.append( QString::number(
id ) );
106 QUrl queryUrl( layerurl +
"/query" );
107 QUrlQuery query( queryUrl );
108 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"json" ) );
109 query.addQueryItem( QStringLiteral(
"objectIds" ), ids.join( QLatin1Char(
',' ) ) );
110 const QString wkid =
crs.indexOf( QLatin1Char(
':' ) ) >= 0 ?
crs.split(
':' )[1] : QString();
111 query.addQueryItem( QStringLiteral(
"inSR" ), wkid );
112 query.addQueryItem( QStringLiteral(
"outSR" ), wkid );
114 query.addQueryItem( QStringLiteral(
"returnGeometry" ), fetchGeometry ? QStringLiteral(
"true" ) : QStringLiteral(
"false" ) );
117 if ( fetchAttributes.isEmpty() )
118 outFields = QStringLiteral(
"*" );
120 outFields = fetchAttributes.join(
',' );
121 query.addQueryItem( QStringLiteral(
"outFields" ), outFields );
123 query.addQueryItem( QStringLiteral(
"returnM" ), fetchM ? QStringLiteral(
"true" ) : QStringLiteral(
"false" ) );
124 query.addQueryItem( QStringLiteral(
"returnZ" ), fetchZ ? QStringLiteral(
"true" ) : QStringLiteral(
"false" ) );
125 if ( !filterRect.
isNull() )
127 query.addQueryItem( QStringLiteral(
"geometry" ), QStringLiteral(
"%1,%2,%3,%4" )
128 .arg( filterRect.
xMinimum(), 0,
'f', -1 ).arg( filterRect.
yMinimum(), 0,
'f', -1 )
129 .arg( filterRect.
xMaximum(), 0,
'f', -1 ).arg( filterRect.
yMaximum(), 0,
'f', -1 ) );
130 query.addQueryItem( QStringLiteral(
"geometryType" ), QStringLiteral(
"esriGeometryEnvelope" ) );
131 query.addQueryItem( QStringLiteral(
"spatialRel" ), QStringLiteral(
"esriSpatialRelEnvelopeIntersects" ) );
133 queryUrl.setQuery( query );
134 return queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders, feedback, urlPrefix );
139 QUrl queryUrl( layerurl +
"/query" );
140 QUrlQuery query( queryUrl );
141 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"json" ) );
142 query.addQueryItem( QStringLiteral(
"where" ), whereClause.isEmpty() ? QStringLiteral(
"1=1" ) : whereClause );
143 query.addQueryItem( QStringLiteral(
"returnIdsOnly" ), QStringLiteral(
"true" ) );
144 query.addQueryItem( QStringLiteral(
"geometry" ), QStringLiteral(
"%1,%2,%3,%4" )
145 .arg( filterRect.
xMinimum(), 0,
'f', -1 ).arg( filterRect.
yMinimum(), 0,
'f', -1 )
146 .arg( filterRect.
xMaximum(), 0,
'f', -1 ).arg( filterRect.
yMaximum(), 0,
'f', -1 ) );
147 query.addQueryItem( QStringLiteral(
"geometryType" ), QStringLiteral(
"esriGeometryEnvelope" ) );
148 query.addQueryItem( QStringLiteral(
"spatialRel" ), QStringLiteral(
"esriSpatialRelEnvelopeIntersects" ) );
149 queryUrl.setQuery( query );
150 const QVariantMap objectIdData =
queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders, feedback, urlPrefix );
152 if ( objectIdData.isEmpty() )
154 return QList<quint32>();
158 const QVariantList objectIdsList = objectIdData[QStringLiteral(
"objectIds" )].toList();
159 ids.reserve( objectIdsList.size() );
160 for (
const QVariant &objectId : objectIdsList )
162 ids << objectId.toInt();
171 if ( !urlPrefix.isEmpty() )
172 url = QUrl( urlPrefix + url.toString() );
174 QNetworkRequest request( url );
189 errorTitle = QStringLiteral(
"Network error" );
193 const QString content = networkRequest.
reply().
content();
194 const thread_local QRegularExpression errorRx( QStringLiteral(
"Error: <.*?>(.*?)<" ) );
195 const QRegularExpressionMatch match = errorRx.match( content );
196 if ( match.hasMatch() )
198 errorText = match.captured( 1 );
206 *contentType = content.
rawHeader(
"Content-Type" );
212 const QByteArray reply =
queryService( url, authcfg, errorTitle, errorText, requestHeaders, feedback,
nullptr, urlPrefix );
213 if ( !errorTitle.isEmpty() )
215 return QVariantMap();
218 return QVariantMap();
222 const QJsonDocument doc = QJsonDocument::fromJson( reply, &err );
225 errorTitle = QStringLiteral(
"Parsing error" );
226 errorText = err.errorString();
227 QgsDebugError( QStringLiteral(
"Parsing error: %1" ).arg( err.errorString() ) );
228 return QVariantMap();
230 const QVariantMap res = doc.object().toVariantMap();
231 if ( res.contains( QStringLiteral(
"error" ) ) )
233 const QVariantMap error = res.value( QStringLiteral(
"error" ) ).toMap();
234 errorText = error.value( QStringLiteral(
"message" ) ).toString();
235 errorTitle = QObject::tr(
"Error %1" ).arg( error.value( QStringLiteral(
"code" ) ).toString() );
236 return QVariantMap();
243 if ( isTestEndpoint )
244 *isTestEndpoint =
false;
246 QUrl modifiedUrl( url );
247 if ( modifiedUrl.toString().contains( QLatin1String(
"fake_qgis_http_endpoint" ) ) )
249 if ( isTestEndpoint )
250 *isTestEndpoint =
true;
253 QString modifiedUrlString = modifiedUrl.toString();
255 modifiedUrlString = QUrl::fromPercentEncoding( modifiedUrlString.toUtf8() );
256 modifiedUrlString.replace( QLatin1String(
"fake_qgis_http_endpoint/" ), QLatin1String(
"fake_qgis_http_endpoint_" ) );
258 modifiedUrlString = modifiedUrlString.mid( QStringLiteral(
"http://" ).size() );
259 QString args = modifiedUrlString.indexOf(
'?' ) >= 0 ? modifiedUrlString.mid( modifiedUrlString.indexOf(
'?' ) ) : QString();
260 if ( modifiedUrlString.size() > 150 )
262 args = QCryptographicHash::hash( args.toUtf8(), QCryptographicHash::Md5 ).toHex();
266 args.replace( QLatin1String(
"?" ), QLatin1String(
"_" ) );
267 args.replace( QLatin1String(
"&" ), QLatin1String(
"_" ) );
268 args.replace( QLatin1String(
"<" ), QLatin1String(
"_" ) );
269 args.replace( QLatin1String(
">" ), QLatin1String(
"_" ) );
270 args.replace( QLatin1String(
"'" ), QLatin1String(
"_" ) );
271 args.replace( QLatin1String(
"\"" ), QLatin1String(
"_" ) );
272 args.replace( QLatin1String(
" " ), QLatin1String(
"_" ) );
273 args.replace( QLatin1String(
":" ), QLatin1String(
"_" ) );
274 args.replace( QLatin1String(
"/" ), QLatin1String(
"_" ) );
275 args.replace( QLatin1String(
"\n" ), QLatin1String(
"_" ) );
280 if ( modifiedUrlString[1] ==
'/' )
282 modifiedUrlString = modifiedUrlString[0] +
":/" + modifiedUrlString.mid( 2 );
285 modifiedUrlString = modifiedUrlString.mid( 0, modifiedUrlString.indexOf(
'?' ) ) + args;
286 QgsDebugMsgLevel( QStringLiteral(
"Get %1 (after laundering)" ).arg( modifiedUrlString ), 2 );
287 modifiedUrl = QUrl::fromLocalFile( modifiedUrlString );
288 if ( !QFile::exists( modifiedUrlString ) )
290 QgsDebugError( QStringLiteral(
"Local test file %1 for URL %2 does not exist!!!" ).arg( modifiedUrlString, url.toString() ) );
297void QgsArcGisRestQueryUtils::adjustBaseUrl( QString &baseUrl,
const QString &name )
299 const QStringList parts = name.split(
'/' );
301 for (
const QString &part : parts )
303 if ( !checkString.isEmpty() )
304 checkString += QString(
'/' );
307 if ( baseUrl.indexOf( QRegularExpression( checkString.replace(
'/', QLatin1String(
"\\/" ) ) + QStringLiteral(
"\\/?$" ) ) ) > -1 )
309 baseUrl = baseUrl.left( baseUrl.length() - checkString.length() - 1 );
317 QString base( baseUrl );
318 bool baseChecked =
false;
319 if ( !base.endsWith(
'/' ) )
320 base += QLatin1Char(
'/' );
322 const QStringList folderList = serviceData.value( QStringLiteral(
"folders" ) ).toStringList();
323 for (
const QString &folder : folderList )
327 adjustBaseUrl( base, folder );
330 visitor( folder, base + folder );
336 QString base( baseUrl );
337 bool baseChecked =
false;
338 if ( !base.endsWith(
'/' ) )
339 base += QLatin1Char(
'/' );
341 const QVariantList serviceList = serviceData.value( QStringLiteral(
"services" ) ).toList();
342 for (
const QVariant &service : serviceList )
344 const QVariantMap serviceMap = service.toMap();
345 const QString serviceTypeString = serviceMap.value( QStringLiteral(
"type" ) ).toString();
348 switch ( serviceType )
364 const QString serviceName = serviceMap.value( QStringLiteral(
"name" ) ).toString();
365 const QString displayName = serviceName.split(
'/' ).last();
368 adjustBaseUrl( base, serviceName );
372 visitor( displayName, base + serviceName +
'/' + serviceTypeString, serviceType );
376void QgsArcGisRestQueryUtils::addLayerItems(
const std::function<
void (
const QString &,
ServiceTypeFilter,
Qgis::GeometryType,
const QString &,
const QString &,
const QString &,
const QString &,
bool,
const QgsCoordinateReferenceSystem &,
const QString & )> &visitor,
const QVariantMap &serviceData,
const QString &parentUrl,
const QString &parentSupportedFormats,
const ServiceTypeFilter filter )
381 const QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats();
382 const QStringList supportedImageFormatTypes = serviceData.value( QStringLiteral(
"supportedImageFormatTypes" ) ).toString().isEmpty() ? parentSupportedFormats.split(
',' ) : serviceData.value( QStringLiteral(
"supportedImageFormatTypes" ) ).toString().split(
',' );
383 QString format = supportedImageFormatTypes.value( 0 );
384 for (
const QString &encoding : supportedImageFormatTypes )
386 for (
const QByteArray &fmt : supportedFormats )
388 if ( encoding.startsWith( fmt, Qt::CaseInsensitive ) )
398 const QStringList capabilities = serviceData.value( QStringLiteral(
"capabilities" ) ).toString().split(
',' );
401 const bool serviceMayHaveQueryCapability = capabilities.contains( QStringLiteral(
"Query" ) ) ||
402 serviceData.value( QStringLiteral(
"serviceDataType" ) ).toString().startsWith( QLatin1String(
"esriImageService" ) );
404 const bool serviceMayRenderMaps = capabilities.contains( QStringLiteral(
"Map" ) ) ||
405 serviceData.value( QStringLiteral(
"serviceDataType" ) ).toString().startsWith( QLatin1String(
"esriImageService" ) );
407 const QVariantList layerInfoList = serviceData.value( QStringLiteral(
"layers" ) ).toList();
408 for (
const QVariant &layerInfo : layerInfoList )
410 const QVariantMap layerInfoMap = layerInfo.toMap();
411 const QString
id = layerInfoMap.value( QStringLiteral(
"id" ) ).toString();
412 const QString parentLayerId = layerInfoMap.value( QStringLiteral(
"parentLayerId" ) ).toString();
413 const QString name = layerInfoMap.value( QStringLiteral(
"name" ) ).toString();
414 const QString description = layerInfoMap.value( QStringLiteral(
"description" ) ).toString();
419 if ( !layerInfoMap.value( QStringLiteral(
"subLayerIds" ) ).toList().empty() )
431 const QString geometryType = layerInfoMap.value( QStringLiteral(
"geometryType" ) ).toString();
442 if ( serviceMayRenderMaps )
444 if ( geometryType.isEmpty() )
452 if ( !layerInfoMap.value( QStringLiteral(
"subLayerIds" ) ).toList().empty() )
463 const QVariantList tableInfoList = serviceData.value( QStringLiteral(
"tables" ) ).toList();
464 for (
const QVariant &tableInfo : tableInfoList )
466 const QVariantMap tableInfoMap = tableInfo.toMap();
467 const QString
id = tableInfoMap.value( QStringLiteral(
"id" ) ).toString();
468 const QString parentLayerId = tableInfoMap.value( QStringLiteral(
"parentLayerId" ) ).toString();
469 const QString name = tableInfoMap.value( QStringLiteral(
"name" ) ).toString();
470 const QString description = tableInfoMap.value( QStringLiteral(
"description" ) ).toString();
474 if ( !tableInfoMap.value( QStringLiteral(
"subLayerIds" ) ).toList().empty() )
486 if ( filter !=
ServiceTypeFilter::Vector && layerInfoList.count() > 1 && serviceData.contains( QStringLiteral(
"supportedImageFormatTypes" ) ) )
488 const QString name = QStringLiteral(
"(%1)" ).arg( QObject::tr(
"All layers" ) );
489 const QString description = serviceData.value( QStringLiteral(
"Comments" ) ).toString();
494 if ( serviceData.value( QStringLiteral(
"serviceDataType" ) ).toString().startsWith( QLatin1String(
"esriImageService" ) ) )
496 const QString name = serviceData.value( QStringLiteral(
"name" ) ).toString();
497 const QString description = serviceData.value( QStringLiteral(
"description" ) ).toString();
509QgsArcGisAsyncQuery::QgsArcGisAsyncQuery( QObject *parent )
514QgsArcGisAsyncQuery::~QgsArcGisAsyncQuery()
517 mReply->deleteLater();
520void QgsArcGisAsyncQuery::start(
const QUrl &url,
const QString &authCfg, QByteArray *result,
bool allowCache,
const QgsHttpHeaders &headers,
const QString &urlPrefix )
524 if ( !urlPrefix.isEmpty() )
525 mUrl = QUrl( urlPrefix + url.toString() );
526 QNetworkRequest request( mUrl );
532 const QString error = tr(
"network request update failed for authentication config" );
533 emit failed( QStringLiteral(
"Network" ), error );
540 request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache );
541 request.setAttribute( QNetworkRequest::CacheSaveControlAttribute,
true );
544 connect( mReply, &QNetworkReply::finished,
this, &QgsArcGisAsyncQuery::handleReply );
547void QgsArcGisAsyncQuery::handleReply()
549 mReply->deleteLater();
551 if ( mReply->error() != QNetworkReply::NoError )
553 QgsDebugError( QStringLiteral(
"Network error: %1" ).arg( mReply->errorString() ) );
554 emit failed( QStringLiteral(
"Network error" ), mReply->errorString() );
559 const QVariant redirect = mReply->attribute( QNetworkRequest::RedirectionTargetAttribute );
562 QNetworkRequest request = mReply->request();
565 request.setUrl( redirect.toUrl() );
567 connect( mReply, &QNetworkReply::finished,
this, &QgsArcGisAsyncQuery::handleReply );
571 *mResult = mReply->readAll();
580QgsArcGisAsyncParallelQuery::QgsArcGisAsyncParallelQuery(
const QString &authcfg,
const QgsHttpHeaders &requestHeaders, QObject *parent )
582 , mAuthCfg( authcfg )
583 , mRequestHeaders( requestHeaders )
587void QgsArcGisAsyncParallelQuery::start(
const QVector<QUrl> &urls, QVector<QByteArray> *results,
bool allowCache )
589 Q_ASSERT( results->size() == urls.size() );
591 mPendingRequests = mResults->size();
592 for (
int i = 0, n = urls.size(); i < n; ++i )
594 QNetworkRequest request( urls[i] );
598 mRequestHeaders.updateNetworkRequest( request );
601 const QString error = tr(
"network request update failed for authentication config" );
602 mErrors.append( error );
607 request.setAttribute( QNetworkRequest::HttpPipeliningAllowedAttribute,
true );
610 request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache );
611 request.setAttribute( QNetworkRequest::CacheSaveControlAttribute,
true );
612 request.setRawHeader(
"Connection",
"keep-alive" );
615 reply->setProperty(
"idx", i );
616 connect( reply, &QNetworkReply::finished,
this, &QgsArcGisAsyncParallelQuery::handleReply );
620void QgsArcGisAsyncParallelQuery::handleReply()
622 QNetworkReply *reply = qobject_cast<QNetworkReply *>( QObject::sender() );
623 const QVariant redirect = reply->attribute( QNetworkRequest::RedirectionTargetAttribute );
624 const int idx = reply->property(
"idx" ).toInt();
625 reply->deleteLater();
626 if ( reply->error() != QNetworkReply::NoError )
629 mErrors.append( reply->errorString() );
635 QNetworkRequest request = reply->request();
638 request.setUrl( redirect.toUrl() );
640 reply->setProperty(
"idx", idx );
641 connect( reply, &QNetworkReply::finished,
this, &QgsArcGisAsyncParallelQuery::handleReply );
646 ( *mResults )[idx] = reply->readAll();
649 if ( mPendingRequests == 0 )
651 emit finished( mErrors );
ArcGisRestServiceType
Available ArcGIS REST service types.
@ GeocodeServer
GeocodeServer.
@ Unknown
Other unknown/unsupported type.
@ GlobeServer
GlobeServer.
@ ImageServer
ImageServer.
@ FeatureServer
FeatureServer.
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
WkbType
The WKB type describes the number of dimensions a geometry has.
static QgsAuthManager * authManager()
Returns the application's authentication manager instance.
static void visitFolderItems(const std::function< void(const QString &folderName, const QString &url)> &visitor, const QVariantMap &serviceData, const QString &baseUrl)
Calls the specified visitor function on all folder items found within the given service data.
static QVariantMap queryServiceJSON(const QUrl &url, const QString &authcfg, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders=QgsHttpHeaders(), QgsFeedback *feedback=nullptr, const QString &urlPrefix=QString())
Performs a blocking request to a URL and returns the retrieved JSON content.
static QVariantMap getObjects(const QString &layerurl, const QString &authcfg, const QList< quint32 > &objectIds, const QString &crs, bool fetchGeometry, const QStringList &fetchAttributes, bool fetchM, bool fetchZ, const QgsRectangle &filterRect, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders=QgsHttpHeaders(), QgsFeedback *feedback=nullptr, const QString &urlPrefix=QString())
Retrieves all matching objects from the specified layer URL.
static QgsRectangle getExtent(const QString &layerurl, const QString &whereClause, const QString &authcfg, const QgsHttpHeaders &requestHeaders=QgsHttpHeaders(), const QString &urlPrefix=QString())
Retrieves the extent for the features matching a whereClause.
static QVariantMap getServiceInfo(const QString &baseurl, const QString &authcfg, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders=QgsHttpHeaders(), const QString &urlPrefix=QString())
Retrieves JSON service info for the specified base URL.
static QVariantMap getObjectIds(const QString &layerurl, const QString &authcfg, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders=QgsHttpHeaders(), const QString &urlPrefix=QString(), const QgsRectangle &bbox=QgsRectangle(), const QString &whereClause=QString())
Retrieves all object IDs for the specified layer URL.
static QUrl parseUrl(const QUrl &url, bool *isTestEndpoint=nullptr)
Parses and processes a url.
ServiceTypeFilter
Service types.
static QVariantMap getLayerInfo(const QString &layerurl, const QString &authcfg, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders=QgsHttpHeaders(), const QString &urlPrefix=QString())
Retrieves JSON layer info for the specified layer URL.
static void addLayerItems(const std::function< void(const QString &parentLayerId, ServiceTypeFilter serviceType, Qgis::GeometryType geometryType, const QString &layerId, const QString &name, const QString &description, const QString &url, bool isParentLayer, const QgsCoordinateReferenceSystem &crs, const QString &format)> &visitor, const QVariantMap &serviceData, const QString &parentUrl, const QString &parentSupportedFormats, const ServiceTypeFilter filter=ServiceTypeFilter::AllTypes)
Calls the specified visitor function on all layer items found within the given service data.
static void visitServiceItems(const std::function< void(const QString &serviceName, const QString &url, Qgis::ArcGisRestServiceType serviceType)> &visitor, const QVariantMap &serviceData, const QString &baseUrl)
Calls the specified visitor function on all service items found within the given service data.
static QByteArray queryService(const QUrl &url, const QString &authcfg, QString &errorTitle, QString &errorText, const QgsHttpHeaders &requestHeaders=QgsHttpHeaders(), QgsFeedback *feedback=nullptr, QString *contentType=nullptr, const QString &urlPrefix=QString())
Performs a blocking request to a URL and returns the retrieved data.
static QList< quint32 > getObjectIdsByExtent(const QString &layerurl, const QgsRectangle &filterRect, QString &errorTitle, QString &errorText, const QString &authcfg, const QgsHttpHeaders &requestHeaders=QgsHttpHeaders(), QgsFeedback *feedback=nullptr, const QString &whereClause=QString(), const QString &urlPrefix=QString())
Gets a list of object IDs which fall within the specified extent.
static QgsCoordinateReferenceSystem convertSpatialReference(const QVariantMap &spatialReferenceMap)
Converts a spatial reference JSON definition to a QgsCoordinateReferenceSystem value.
static Qgis::WkbType convertGeometryType(const QString &type)
Converts an ESRI REST geometry type to a WKB type.
static Qgis::ArcGisRestServiceType serviceTypeFromString(const QString &type)
Converts a string value to a REST service type.
static QgsRectangle convertRectangle(const QVariant &value)
Converts a rectangle value to a QgsRectangle.
bool updateNetworkRequest(QNetworkRequest &request, const QString &authcfg, const QString &dataprovider=QString())
Provider call to update a QNetworkRequest with an authentication config.
A thread safe class for performing blocking (sync) network requests, with full support for QGIS proxy...
void setAuthCfg(const QString &authCfg)
Sets the authentication config id which should be used during the request.
QString errorMessage() const
Returns the error message string, after a get(), post(), head() or put() request has been made.
ErrorCode get(QNetworkRequest &request, bool forceRefresh=false, QgsFeedback *feedback=nullptr, RequestFlags requestFlags=QgsBlockingNetworkRequest::RequestFlags())
Performs a "get" operation on the specified request.
@ NoError
No error was encountered.
QgsNetworkReplyContent reply() const
Returns the content of the network reply, after a get(), post(), head() or put() request has been mad...
This class represents a coordinate reference system (CRS).
Base class for feedback objects to be used for cancellation of something running in a worker thread.
bool isCanceled() const
Tells whether the operation has been canceled already.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
static QgsNetworkAccessManager * instance(Qt::ConnectionType connectionType=Qt::BlockingQueuedConnection)
Returns a pointer to the active QgsNetworkAccessManager for the current thread.
Encapsulates a network reply within a container which is inexpensive to copy and safe to pass between...
QByteArray content() const
Returns the reply content.
QByteArray rawHeader(const QByteArray &headerName) const
Returns the content of the header with the specified headerName, or an empty QByteArray if the specif...
A rectangle specified with double values.
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
static Qgis::GeometryType geometryType(Qgis::WkbType type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
#define QgsSetRequestInitiatorClass(request, _class)
#define QgsSetRequestInitiatorId(request, str)
const QgsCoordinateReferenceSystem & crs