29#include <QImageReader>
30#include <QRegularExpression>
31#include <QJsonParseError>
36 QUrl queryUrl( baseurl );
37 QUrlQuery query( queryUrl );
38 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"json" ) );
39 queryUrl.setQuery( query );
40 return queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders,
nullptr, urlPrefix );
46 QUrl queryUrl( layerurl );
47 QUrlQuery query( queryUrl );
48 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"json" ) );
49 queryUrl.setQuery( query );
50 return queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders,
nullptr, urlPrefix );
56 QUrl queryUrl( layerurl +
"/query" );
57 QUrlQuery query( queryUrl );
58 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"json" ) );
59 query.addQueryItem( QStringLiteral(
"where" ), whereClause.isEmpty() ? QStringLiteral(
"1=1" ) : whereClause );
60 query.addQueryItem( QStringLiteral(
"returnIdsOnly" ), QStringLiteral(
"true" ) );
63 query.addQueryItem( QStringLiteral(
"geometry" ), QStringLiteral(
"%1,%2,%3,%4" )
66 query.addQueryItem( QStringLiteral(
"geometryType" ), QStringLiteral(
"esriGeometryEnvelope" ) );
67 query.addQueryItem( QStringLiteral(
"spatialRel" ), QStringLiteral(
"esriSpatialRelEnvelopeIntersects" ) );
69 queryUrl.setQuery( query );
70 return queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders,
nullptr, urlPrefix );
76 QUrl queryUrl( layerurl +
"/query" );
77 QUrlQuery query( queryUrl );
78 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"json" ) );
79 query.addQueryItem( QStringLiteral(
"where" ), whereClause );
80 query.addQueryItem( QStringLiteral(
"returnExtentOnly" ), QStringLiteral(
"true" ) );
81 queryUrl.setQuery( query );
84 const QVariantMap res =
queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders,
nullptr, urlPrefix );
87 QgsDebugError( QStringLiteral(
"getExtent failed: %1 - %2" ).arg( errorTitle, errorText ) );
95 bool fetchGeometry,
const QStringList &fetchAttributes,
96 bool fetchM,
bool fetchZ,
98 QString &errorTitle, QString &errorText,
const QgsHttpHeaders &requestHeaders,
QgsFeedback *feedback,
const QString &urlPrefix )
101 for (
const int id : objectIds )
103 ids.append( QString::number(
id ) );
105 QUrl queryUrl( layerurl +
"/query" );
106 QUrlQuery query( queryUrl );
107 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"json" ) );
108 query.addQueryItem( QStringLiteral(
"objectIds" ), ids.join( QLatin1Char(
',' ) ) );
109 const QString wkid =
crs.indexOf( QLatin1Char(
':' ) ) >= 0 ?
crs.split(
':' )[1] : QString();
110 query.addQueryItem( QStringLiteral(
"inSR" ), wkid );
111 query.addQueryItem( QStringLiteral(
"outSR" ), wkid );
113 query.addQueryItem( QStringLiteral(
"returnGeometry" ), fetchGeometry ? QStringLiteral(
"true" ) : QStringLiteral(
"false" ) );
116 if ( fetchAttributes.isEmpty() )
117 outFields = QStringLiteral(
"*" );
119 outFields = fetchAttributes.join(
',' );
120 query.addQueryItem( QStringLiteral(
"outFields" ), outFields );
122 query.addQueryItem( QStringLiteral(
"returnM" ), fetchM ? QStringLiteral(
"true" ) : QStringLiteral(
"false" ) );
123 query.addQueryItem( QStringLiteral(
"returnZ" ), fetchZ ? QStringLiteral(
"true" ) : QStringLiteral(
"false" ) );
124 if ( !filterRect.
isNull() )
126 query.addQueryItem( QStringLiteral(
"geometry" ), QStringLiteral(
"%1,%2,%3,%4" )
127 .arg( filterRect.
xMinimum(), 0,
'f', -1 ).arg( filterRect.
yMinimum(), 0,
'f', -1 )
128 .arg( filterRect.
xMaximum(), 0,
'f', -1 ).arg( filterRect.
yMaximum(), 0,
'f', -1 ) );
129 query.addQueryItem( QStringLiteral(
"geometryType" ), QStringLiteral(
"esriGeometryEnvelope" ) );
130 query.addQueryItem( QStringLiteral(
"spatialRel" ), QStringLiteral(
"esriSpatialRelEnvelopeIntersects" ) );
132 queryUrl.setQuery( query );
133 return queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders, feedback, urlPrefix );
138 QUrl queryUrl( layerurl +
"/query" );
139 QUrlQuery query( queryUrl );
140 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"json" ) );
141 query.addQueryItem( QStringLiteral(
"where" ), whereClause.isEmpty() ? QStringLiteral(
"1=1" ) : whereClause );
142 query.addQueryItem( QStringLiteral(
"returnIdsOnly" ), QStringLiteral(
"true" ) );
143 query.addQueryItem( QStringLiteral(
"geometry" ), QStringLiteral(
"%1,%2,%3,%4" )
144 .arg( filterRect.
xMinimum(), 0,
'f', -1 ).arg( filterRect.
yMinimum(), 0,
'f', -1 )
145 .arg( filterRect.
xMaximum(), 0,
'f', -1 ).arg( filterRect.
yMaximum(), 0,
'f', -1 ) );
146 query.addQueryItem( QStringLiteral(
"geometryType" ), QStringLiteral(
"esriGeometryEnvelope" ) );
147 query.addQueryItem( QStringLiteral(
"spatialRel" ), QStringLiteral(
"esriSpatialRelEnvelopeIntersects" ) );
148 queryUrl.setQuery( query );
149 const QVariantMap objectIdData =
queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders, feedback, urlPrefix );
151 if ( objectIdData.isEmpty() )
153 return QList<quint32>();
157 const QVariantList objectIdsList = objectIdData[QStringLiteral(
"objectIds" )].toList();
158 ids.reserve( objectIdsList.size() );
159 for (
const QVariant &objectId : objectIdsList )
161 ids << objectId.toInt();
170 if ( !urlPrefix.isEmpty() )
171 url = QUrl( urlPrefix + url.toString() );
173 QNetworkRequest request( url );
188 errorTitle = QStringLiteral(
"Network error" );
192 const QString content = networkRequest.
reply().
content();
193 const thread_local QRegularExpression errorRx( QStringLiteral(
"Error: <.*?>(.*?)<" ) );
194 const QRegularExpressionMatch match = errorRx.match( content );
195 if ( match.hasMatch() )
197 errorText = match.captured( 1 );
205 *contentType = content.
rawHeader(
"Content-Type" );
211 const QByteArray reply =
queryService( url, authcfg, errorTitle, errorText, requestHeaders, feedback,
nullptr, urlPrefix );
212 if ( !errorTitle.isEmpty() )
214 return QVariantMap();
217 return QVariantMap();
221 const QJsonDocument doc = QJsonDocument::fromJson( reply, &err );
224 errorTitle = QStringLiteral(
"Parsing error" );
225 errorText = err.errorString();
226 QgsDebugError( QStringLiteral(
"Parsing error: %1" ).arg( err.errorString() ) );
227 return QVariantMap();
229 const QVariantMap res = doc.object().toVariantMap();
230 if ( res.contains( QStringLiteral(
"error" ) ) )
232 const QVariantMap error = res.value( QStringLiteral(
"error" ) ).toMap();
233 errorText = error.value( QStringLiteral(
"message" ) ).toString();
234 errorTitle = QObject::tr(
"Error %1" ).arg( error.value( QStringLiteral(
"code" ) ).toString() );
235 return QVariantMap();
242 if ( isTestEndpoint )
243 *isTestEndpoint =
false;
245 QUrl modifiedUrl( url );
246 if ( modifiedUrl.toString().contains( QLatin1String(
"fake_qgis_http_endpoint" ) ) )
248 if ( isTestEndpoint )
249 *isTestEndpoint =
true;
252 QString modifiedUrlString = modifiedUrl.toString();
254 modifiedUrlString = QUrl::fromPercentEncoding( modifiedUrlString.toUtf8() );
255 modifiedUrlString.replace( QLatin1String(
"fake_qgis_http_endpoint/" ), QLatin1String(
"fake_qgis_http_endpoint_" ) );
257 modifiedUrlString = modifiedUrlString.mid( QStringLiteral(
"http://" ).size() );
258 QString args = modifiedUrlString.indexOf(
'?' ) >= 0 ? modifiedUrlString.mid( modifiedUrlString.indexOf(
'?' ) ) : QString();
259 if ( modifiedUrlString.size() > 150 )
261 args = QCryptographicHash::hash( args.toUtf8(), QCryptographicHash::Md5 ).toHex();
265 args.replace( QLatin1String(
"?" ), QLatin1String(
"_" ) );
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(
"\n" ), QLatin1String(
"_" ) );
279 if ( modifiedUrlString[1] ==
'/' )
281 modifiedUrlString = modifiedUrlString[0] +
":/" + modifiedUrlString.mid( 2 );
284 modifiedUrlString = modifiedUrlString.mid( 0, modifiedUrlString.indexOf(
'?' ) ) + args;
285 QgsDebugMsgLevel( QStringLiteral(
"Get %1 (after laundering)" ).arg( modifiedUrlString ), 2 );
286 modifiedUrl = QUrl::fromLocalFile( modifiedUrlString );
287 if ( !QFile::exists( modifiedUrlString ) )
289 QgsDebugError( QStringLiteral(
"Local test file %1 for URL %2 does not exist!!!" ).arg( modifiedUrlString, url.toString() ) );
296void QgsArcGisRestQueryUtils::adjustBaseUrl( QString &baseUrl,
const QString &name )
298 const QStringList parts = name.split(
'/' );
300 for (
const QString &part : parts )
302 if ( !checkString.isEmpty() )
303 checkString += QString(
'/' );
306 if ( baseUrl.indexOf( QRegularExpression( checkString.replace(
'/', QLatin1String(
"\\/" ) ) + QStringLiteral(
"\\/?$" ) ) ) > -1 )
308 baseUrl = baseUrl.left( baseUrl.length() - checkString.length() - 1 );
316 QString base( baseUrl );
317 bool baseChecked =
false;
318 if ( !base.endsWith(
'/' ) )
319 base += QLatin1Char(
'/' );
321 const QStringList folderList = serviceData.value( QStringLiteral(
"folders" ) ).toStringList();
322 for (
const QString &folder : folderList )
326 adjustBaseUrl( base, folder );
329 visitor( folder, base + folder );
335 QString base( baseUrl );
336 bool baseChecked =
false;
337 if ( !base.endsWith(
'/' ) )
338 base += QLatin1Char(
'/' );
340 const QVariantList serviceList = serviceData.value( QStringLiteral(
"services" ) ).toList();
341 for (
const QVariant &service : serviceList )
343 const QVariantMap serviceMap = service.toMap();
344 const QString serviceTypeString = serviceMap.value( QStringLiteral(
"type" ) ).toString();
347 switch ( serviceType )
363 const QString serviceName = serviceMap.value( QStringLiteral(
"name" ) ).toString();
364 const QString displayName = serviceName.split(
'/' ).last();
367 adjustBaseUrl( base, serviceName );
371 visitor( displayName, base + serviceName +
'/' + serviceTypeString, serviceType );
375void 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 )
380 const QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats();
381 const QStringList supportedImageFormatTypes = serviceData.value( QStringLiteral(
"supportedImageFormatTypes" ) ).toString().isEmpty() ? parentSupportedFormats.split(
',' ) : serviceData.value( QStringLiteral(
"supportedImageFormatTypes" ) ).toString().split(
',' );
382 QString format = supportedImageFormatTypes.value( 0 );
383 for (
const QString &encoding : supportedImageFormatTypes )
385 for (
const QByteArray &fmt : supportedFormats )
387 if ( encoding.startsWith( fmt, Qt::CaseInsensitive ) )
397 const QStringList capabilities = serviceData.value( QStringLiteral(
"capabilities" ) ).toString().split(
',' );
400 const bool serviceMayHaveQueryCapability = capabilities.contains( QStringLiteral(
"Query" ) ) ||
401 serviceData.value( QStringLiteral(
"serviceDataType" ) ).toString().startsWith( QLatin1String(
"esriImageService" ) );
403 const bool serviceMayRenderMaps = capabilities.contains( QStringLiteral(
"Map" ) ) ||
404 serviceData.value( QStringLiteral(
"serviceDataType" ) ).toString().startsWith( QLatin1String(
"esriImageService" ) );
406 const QVariantList layerInfoList = serviceData.value( QStringLiteral(
"layers" ) ).toList();
407 for (
const QVariant &layerInfo : layerInfoList )
409 const QVariantMap layerInfoMap = layerInfo.toMap();
410 const QString
id = layerInfoMap.value( QStringLiteral(
"id" ) ).toString();
411 const QString parentLayerId = layerInfoMap.value( QStringLiteral(
"parentLayerId" ) ).toString();
412 const QString name = layerInfoMap.value( QStringLiteral(
"name" ) ).toString();
413 const QString description = layerInfoMap.value( QStringLiteral(
"description" ) ).toString();
418 if ( !layerInfoMap.value( QStringLiteral(
"subLayerIds" ) ).toList().empty() )
430 const QString geometryType = layerInfoMap.value( QStringLiteral(
"geometryType" ) ).toString();
441 if ( serviceMayRenderMaps )
443 if ( geometryType.isEmpty() )
451 if ( !layerInfoMap.value( QStringLiteral(
"subLayerIds" ) ).toList().empty() )
462 const QVariantList tableInfoList = serviceData.value( QStringLiteral(
"tables" ) ).toList();
463 for (
const QVariant &tableInfo : tableInfoList )
465 const QVariantMap tableInfoMap = tableInfo.toMap();
466 const QString
id = tableInfoMap.value( QStringLiteral(
"id" ) ).toString();
467 const QString parentLayerId = tableInfoMap.value( QStringLiteral(
"parentLayerId" ) ).toString();
468 const QString name = tableInfoMap.value( QStringLiteral(
"name" ) ).toString();
469 const QString description = tableInfoMap.value( QStringLiteral(
"description" ) ).toString();
473 if ( !tableInfoMap.value( QStringLiteral(
"subLayerIds" ) ).toList().empty() )
485 if ( filter !=
ServiceTypeFilter::Vector && layerInfoList.count() > 1 && serviceData.contains( QStringLiteral(
"supportedImageFormatTypes" ) ) )
487 const QString name = QStringLiteral(
"(%1)" ).arg( QObject::tr(
"All layers" ) );
488 const QString description = serviceData.value( QStringLiteral(
"Comments" ) ).toString();
493 if ( serviceData.value( QStringLiteral(
"serviceDataType" ) ).toString().startsWith( QLatin1String(
"esriImageService" ) ) )
495 const QString name = serviceData.value( QStringLiteral(
"name" ) ).toString();
496 const QString description = serviceData.value( QStringLiteral(
"description" ) ).toString();
508QgsArcGisAsyncQuery::QgsArcGisAsyncQuery( QObject *parent )
513QgsArcGisAsyncQuery::~QgsArcGisAsyncQuery()
516 mReply->deleteLater();
519void QgsArcGisAsyncQuery::start(
const QUrl &url,
const QString &authCfg, QByteArray *result,
bool allowCache,
const QgsHttpHeaders &headers,
const QString &urlPrefix )
523 if ( !urlPrefix.isEmpty() )
524 mUrl = QUrl( urlPrefix + url.toString() );
525 QNetworkRequest request( mUrl );
531 const QString error = tr(
"network request update failed for authentication config" );
532 emit failed( QStringLiteral(
"Network" ), error );
539 request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache );
540 request.setAttribute( QNetworkRequest::CacheSaveControlAttribute,
true );
543 connect( mReply, &QNetworkReply::finished,
this, &QgsArcGisAsyncQuery::handleReply );
546void QgsArcGisAsyncQuery::handleReply()
548 mReply->deleteLater();
550 if ( mReply->error() != QNetworkReply::NoError )
552 QgsDebugError( QStringLiteral(
"Network error: %1" ).arg( mReply->errorString() ) );
553 emit failed( QStringLiteral(
"Network error" ), mReply->errorString() );
558 const QVariant redirect = mReply->attribute( QNetworkRequest::RedirectionTargetAttribute );
561 QNetworkRequest request = mReply->request();
564 request.setUrl( redirect.toUrl() );
566 connect( mReply, &QNetworkReply::finished,
this, &QgsArcGisAsyncQuery::handleReply );
570 *mResult = mReply->readAll();
579QgsArcGisAsyncParallelQuery::QgsArcGisAsyncParallelQuery(
const QString &authcfg,
const QgsHttpHeaders &requestHeaders, QObject *parent )
581 , mAuthCfg( authcfg )
582 , mRequestHeaders( requestHeaders )
586void QgsArcGisAsyncParallelQuery::start(
const QVector<QUrl> &urls, QVector<QByteArray> *results,
bool allowCache )
588 Q_ASSERT( results->size() == urls.size() );
590 mPendingRequests = mResults->size();
591 for (
int i = 0, n = urls.size(); i < n; ++i )
593 QNetworkRequest request( urls[i] );
597 mRequestHeaders.updateNetworkRequest( request );
600 const QString error = tr(
"network request update failed for authentication config" );
601 mErrors.append( error );
606 request.setAttribute( QNetworkRequest::HttpPipeliningAllowedAttribute,
true );
609 request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache );
610 request.setAttribute( QNetworkRequest::CacheSaveControlAttribute,
true );
611 request.setRawHeader(
"Connection",
"keep-alive" );
614 reply->setProperty(
"idx", i );
615 connect( reply, &QNetworkReply::finished,
this, &QgsArcGisAsyncParallelQuery::handleReply );
619void QgsArcGisAsyncParallelQuery::handleReply()
621 QNetworkReply *reply = qobject_cast<QNetworkReply *>( QObject::sender() );
622 const QVariant redirect = reply->attribute( QNetworkRequest::RedirectionTargetAttribute );
623 const int idx = reply->property(
"idx" ).toInt();
624 reply->deleteLater();
625 if ( reply->error() != QNetworkReply::NoError )
628 mErrors.append( reply->errorString() );
634 QNetworkRequest request = reply->request();
637 request.setUrl( redirect.toUrl() );
639 reply->setProperty(
"idx", idx );
640 connect( reply, &QNetworkReply::finished,
this, &QgsArcGisAsyncParallelQuery::handleReply );
645 ( *mResults )[idx] = reply->readAll();
648 if ( mPendingRequests == 0 )
650 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.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
double xMaximum() const
Returns the x maximum value (right side of rectangle).
bool isNull() const
Test if the rectangle is null (holding no spatial information).
double yMaximum() const
Returns the y maximum value (top side of rectangle).
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