QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgssensorthingsprovider.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgssensorthingsprovider.cpp
3 ----------------
4 begin : November 2023
5 copyright : (C) 2013 Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
19
20#include <nlohmann/json.hpp>
21
22#include "qgsapplication.h"
24#include "qgsmessagelog.h"
25#include "qgsreadwritelocker.h"
31#include "qgsthreadingutils.h"
32
33#include <QIcon>
34#include <QNetworkRequest>
35
36#include "moc_qgssensorthingsprovider.cpp"
37
39
40QgsSensorThingsProvider::QgsSensorThingsProvider( const QString &uri, const ProviderOptions &options, Qgis::DataProviderReadFlags flags )
41 : QgsVectorDataProvider( uri, options, flags )
42{
43 mSharedData = std::make_shared< QgsSensorThingsSharedData >( uri );
44
45 const QUrl url( QgsSensorThingsSharedData::parseUrl( mSharedData->mRootUri ) );
46
47 QNetworkRequest request = QNetworkRequest( url );
48 QgsSetRequestInitiatorClass( request, QStringLiteral( "QgsSensorThingsProvider" ) )
49 mSharedData->mHeaders.updateNetworkRequest( request );
50
51 QgsBlockingNetworkRequest networkRequest;
52 networkRequest.setAuthCfg( mSharedData->mAuthCfg );
53
54 switch ( networkRequest.get( request ) )
55 {
57 break;
58
62 appendError( QgsErrorMessage( tr( "Connection failed: %1" ).arg( networkRequest.errorMessage() ), QStringLiteral( "SensorThings" ) ) );
63 return;
64 }
65
66 const QgsNetworkReplyContent content = networkRequest.reply();
67
68 try
69 {
70 auto rootContent = json::parse( content.content().toStdString() );
71 if ( !rootContent.contains( "value" ) )
72 {
73 appendError( QgsErrorMessage( tr( "No 'value' array in response" ), QStringLiteral( "SensorThings" ) ) );
74 return;
75 }
76
77 bool foundMatchingEntity = false;
78 for ( const auto &valueJson : rootContent["value"] )
79 {
80 if ( valueJson.contains( "name" ) && valueJson.contains( "url" ) )
81 {
82 const QString name = QString::fromStdString( valueJson["name"].get<std::string>() );
84 if ( entityType == mSharedData->mEntityType )
85 {
86 const QString url = QString::fromStdString( valueJson["url"].get<std::string>() );
87 if ( !url.isEmpty() )
88 {
89 foundMatchingEntity = true;
90 mSharedData->mEntityBaseUri = url;
91
92 // TODO:
93 // if we always retrieve feature count, is that less expensive then deferring this till we need it?
94 // by retrieving upfront, we can save a lot of requests where we've fetched features from spatial extents
95 // as we'll have a way of determining whether we've fetched all features from the source. Otherwise
96 // we never know if we've got everything yet, and are forced to re-fetched everything when a non-filtered request
97 // comes in...
98 ( void ) mSharedData->featureCount();
99 }
100 }
101 }
102 }
103
104 if ( !foundMatchingEntity )
105 {
106 switch ( mSharedData->mEntityType )
107 {
108
118 appendError( QgsErrorMessage( tr( "Could not find url for %1" ).arg( qgsEnumValueToKey( mSharedData->mEntityType ) ), QStringLiteral( "SensorThings" ) ) );
119 QgsMessageLog::logMessage( tr( "Could not find url for %1" ).arg( qgsEnumValueToKey( mSharedData->mEntityType ) ), tr( "SensorThings" ) );
120 break;
121
123 appendError( QgsErrorMessage( tr( "MultiDatastreams are not supported by this connection" ), QStringLiteral( "SensorThings" ) ) );
124 QgsMessageLog::logMessage( tr( "MultiDatastreams are not supported by this connection" ), tr( "SensorThings" ) );
125 break;
126 }
127
128 return;
129 }
130 }
131 catch ( const json::parse_error &ex )
132 {
133 appendError( QgsErrorMessage( tr( "Error parsing response: %1" ).arg( ex.what() ), QStringLiteral( "SensorThings" ) ) );
134 return;
135 }
136
137 mValid = true;
138}
139
140QString QgsSensorThingsProvider::storageType() const
141{
143
144 return QStringLiteral( "OGC SensorThings API" );
145}
146
147QgsAbstractFeatureSource *QgsSensorThingsProvider::featureSource() const
148{
150
151 return new QgsSensorThingsFeatureSource( mSharedData );
152}
153
154QgsFeatureIterator QgsSensorThingsProvider::getFeatures( const QgsFeatureRequest &request ) const
155{
157
158 return new QgsSensorThingsFeatureIterator( new QgsSensorThingsFeatureSource( mSharedData ), true, request );
159}
160
161Qgis::WkbType QgsSensorThingsProvider::wkbType() const
162{
164
165 return mSharedData->mGeometryType;
166}
167
168long long QgsSensorThingsProvider::featureCount() const
169{
171
172 if ( ( mReadFlags & Qgis::DataProviderReadFlag::SkipFeatureCount ) != 0 )
173 {
174 return static_cast< long long >( Qgis::FeatureCountState::UnknownCount );
175 }
176
177 const long long count = mSharedData->featureCount();
178 if ( !mSharedData->error().isEmpty() )
179 pushError( mSharedData->error() );
180
181 return count;
182}
183
184QgsFields QgsSensorThingsProvider::fields() const
185{
187
188 return mSharedData->mFields;
189}
190
191QgsLayerMetadata QgsSensorThingsProvider::layerMetadata() const
192{
194
195 return mLayerMetadata;
196}
197
198QString QgsSensorThingsProvider::htmlMetadata() const
199{
201
202 QString metadata;
203
204 QgsReadWriteLocker locker( mSharedData->mReadWriteLock, QgsReadWriteLocker::Read );
205
206 metadata += QStringLiteral( "<tr><td class=\"highlight\">" ) % tr( "Entity Type" ) % QStringLiteral( "</td><td>%1" ).arg( qgsEnumValueToKey( mSharedData->mEntityType ) ) % QStringLiteral( "</td></tr>\n" );
207 metadata += QStringLiteral( "<tr><td class=\"highlight\">" ) % tr( "Endpoint" ) % QStringLiteral( "</td><td><a href=\"%1\">%1</a>" ).arg( mSharedData->mEntityBaseUri ) % QStringLiteral( "</td></tr>\n" );
208
209 return metadata;
210}
211
212Qgis::DataProviderFlags QgsSensorThingsProvider::flags() const
213{
215
217}
218
219Qgis::VectorProviderCapabilities QgsSensorThingsProvider::capabilities() const
220{
222
226
227 return c;
228}
229
230bool QgsSensorThingsProvider::supportsSubsetString() const
231{
233 return true;
234}
235
236QString QgsSensorThingsProvider::subsetStringDialect() const
237{
238 return tr( "OGC SensorThings filter" );
239}
240
241QString QgsSensorThingsProvider::subsetStringHelpUrl() const
242{
243 return QStringLiteral( "https://docs.ogc.org/is/18-088/18-088.html#filter" );
244}
245
246QString QgsSensorThingsProvider::subsetString() const
247{
249 return mSharedData->subsetString();
250}
251
252bool QgsSensorThingsProvider::setSubsetString( const QString &subset, bool )
253{
255
256 const QString trimmedSubset = subset.trimmed();
257 if ( trimmedSubset == mSharedData->subsetString() )
258 return true;
259
260 // store this and restore it after the data source is changed,
261 // to avoid an unwanted network request to retrieve this again
262 const QString baseUri = mSharedData->mEntityBaseUri;
263
264 QgsDataSourceUri uri = dataSourceUri();
265 uri.setSql( trimmedSubset );
266 setDataSourceUri( uri.uri( false ) );
267
268 mSharedData->mEntityBaseUri = baseUri;
269
270 clearMinMaxCache();
271
272 emit dataChanged();
273
274 return true;
275}
276
277void QgsSensorThingsProvider::setDataSourceUri( const QString &uri )
278{
280
281 mSharedData = std::make_shared< QgsSensorThingsSharedData >( uri );
283}
284
285QgsCoordinateReferenceSystem QgsSensorThingsProvider::crs() const
286{
288
289 return mSharedData->mSourceCRS;
290}
291
292QgsRectangle QgsSensorThingsProvider::extent() const
293{
295 return mSharedData->extent();
296}
297
298QString QgsSensorThingsProvider::name() const
299{
301
302 return SENSORTHINGS_PROVIDER_KEY;
303}
304
305QString QgsSensorThingsProvider::providerKey()
306{
307 return SENSORTHINGS_PROVIDER_KEY;
308}
309
310void QgsSensorThingsProvider::handlePostCloneOperations( QgsVectorDataProvider *source )
311{
312 mSharedData = qobject_cast<QgsSensorThingsProvider *>( source )->mSharedData;
313}
314
315QString QgsSensorThingsProvider::description() const
316{
317 return SENSORTHINGS_PROVIDER_DESCRIPTION;
318}
319
320bool QgsSensorThingsProvider::renderInPreview( const PreviewContext & )
321{
322 // be nice to the endpoint and don't make any requests we don't have to!
323 return false;
324}
325
326void QgsSensorThingsProvider::reloadProviderData()
327{
328#if 0
329 mSharedData->clearCache();
330#endif
331}
332
333//
334// QgsSensorThingsProviderMetadata
335//
336
337QgsSensorThingsProviderMetadata::QgsSensorThingsProviderMetadata():
338 QgsProviderMetadata( QgsSensorThingsProvider::SENSORTHINGS_PROVIDER_KEY, QgsSensorThingsProvider::SENSORTHINGS_PROVIDER_DESCRIPTION )
339{
340}
341
342QIcon QgsSensorThingsProviderMetadata::icon() const
343{
344 return QgsApplication::getThemeIcon( QStringLiteral( "mIconSensorThings.svg" ) );
345}
346
347QList<QgsDataItemProvider *> QgsSensorThingsProviderMetadata::dataItemProviders() const
348{
349 return { new QgsSensorThingsDataItemProvider() };
350}
351
352QVariantMap QgsSensorThingsProviderMetadata::decodeUri( const QString &uri ) const
353{
354 const QgsDataSourceUri dsUri = QgsDataSourceUri( uri );
355
356 QVariantMap components;
357 components.insert( QStringLiteral( "url" ), dsUri.param( QStringLiteral( "url" ) ) );
358
359 if ( !dsUri.authConfigId().isEmpty() )
360 {
361 components.insert( QStringLiteral( "authcfg" ), dsUri.authConfigId() );
362 }
363 if ( !dsUri.username().isEmpty() )
364 {
365 components.insert( QStringLiteral( "username" ), dsUri.username() );
366 }
367 if ( !dsUri.password().isEmpty() )
368 {
369 components.insert( QStringLiteral( "password" ), dsUri.password() );
370 }
371
372 // there's two different ways the referer can be set, so we need to check both. Which way it has been
373 // set depends on the widget used to create the URI. It's messy, but QgsHttpHeaders has a bunch of logic in
374 // it to handle upgrading old referer handling for connections created before QgsHttpHeaders was invented,
375 // and if we rely on that entirely then we get multiple "referer" parameters included in the URI, which is
376 // both ugly and unnecessary for a provider created post QgsHttpHeaders.
377 if ( !dsUri.param( QStringLiteral( "referer" ) ).isEmpty() )
378 {
379 components.insert( QStringLiteral( "referer" ), dsUri.param( QStringLiteral( "referer" ) ) );
380 }
381 if ( !dsUri.param( QStringLiteral( "http-header:referer" ) ).isEmpty() )
382 {
383 components.insert( QStringLiteral( "referer" ), dsUri.param( QStringLiteral( "http-header:referer" ) ) );
384 }
385
386 const QString entityParam = dsUri.param( QStringLiteral( "entity" ) );
388 if ( entity == Qgis::SensorThingsEntity::Invalid )
389 entity = QgsSensorThingsUtils::stringToEntity( entityParam );
390
391 if ( entity != Qgis::SensorThingsEntity::Invalid )
392 components.insert( QStringLiteral( "entity" ), qgsEnumValueToKey( entity ) );
393
394 const QStringList expandToParam = dsUri.param( QStringLiteral( "expandTo" ) ).split( ';', Qt::SkipEmptyParts );
395 if ( !expandToParam.isEmpty() )
396 {
397 QVariantList expandParts;
398 for ( const QString &expandString : expandToParam )
399 {
401 if ( definition.isValid() )
402 {
403 expandParts.append( QVariant::fromValue( definition ) );
404 }
405 }
406 if ( !expandParts.isEmpty() )
407 {
408 components.insert( QStringLiteral( "expandTo" ), expandParts );
409 }
410 }
411
412 bool ok = false;
413 const int maxPageSizeParam = dsUri.param( QStringLiteral( "pageSize" ) ).toInt( &ok );
414 if ( ok )
415 {
416 components.insert( QStringLiteral( "pageSize" ), maxPageSizeParam );
417 }
418
419 ok = false;
420 const int featureLimitParam = dsUri.param( QStringLiteral( "featureLimit" ) ).toInt( &ok );
421 if ( ok )
422 {
423 components.insert( QStringLiteral( "featureLimit" ), featureLimitParam );
424 }
425
426 switch ( QgsWkbTypes::geometryType( dsUri.wkbType() ) )
427 {
429 if ( QgsWkbTypes::isMultiType( dsUri.wkbType() ) )
430 components.insert( QStringLiteral( "geometryType" ), QStringLiteral( "multipoint" ) );
431 else
432 components.insert( QStringLiteral( "geometryType" ), QStringLiteral( "point" ) );
433 break;
435 components.insert( QStringLiteral( "geometryType" ), QStringLiteral( "line" ) );
436 break;
438 components.insert( QStringLiteral( "geometryType" ), QStringLiteral( "polygon" ) );
439 break;
440
443 break;
444 }
445
446 const QStringList bbox = dsUri.param( QStringLiteral( "bbox" ) ).split( ',' );
447 if ( bbox.size() == 4 )
448 {
449 QgsRectangle r;
450 bool xminOk = false;
451 bool yminOk = false;
452 bool xmaxOk = false;
453 bool ymaxOk = false;
454 r.setXMinimum( bbox[0].toDouble( &xminOk ) );
455 r.setYMinimum( bbox[1].toDouble( &yminOk ) );
456 r.setXMaximum( bbox[2].toDouble( &xmaxOk ) );
457 r.setYMaximum( bbox[3].toDouble( &ymaxOk ) );
458 if ( xminOk && yminOk && xmaxOk && ymaxOk )
459 components.insert( QStringLiteral( "bounds" ), r );
460 }
461
462 if ( !dsUri.sql().isEmpty() )
463 components.insert( QStringLiteral( "sql" ), dsUri.sql() );
464
465 return components;
466}
467
468QString QgsSensorThingsProviderMetadata::encodeUri( const QVariantMap &parts ) const
469{
470 QgsDataSourceUri dsUri;
471 dsUri.setParam( QStringLiteral( "url" ), parts.value( QStringLiteral( "url" ) ).toString() );
472
473 if ( !parts.value( QStringLiteral( "authcfg" ) ).toString().isEmpty() )
474 {
475 dsUri.setAuthConfigId( parts.value( QStringLiteral( "authcfg" ) ).toString() );
476 }
477 if ( !parts.value( QStringLiteral( "username" ) ).toString().isEmpty() )
478 {
479 dsUri.setUsername( parts.value( QStringLiteral( "username" ) ).toString() );
480 }
481 if ( !parts.value( QStringLiteral( "password" ) ).toString().isEmpty() )
482 {
483 dsUri.setPassword( parts.value( QStringLiteral( "password" ) ).toString() );
484 }
485 if ( !parts.value( QStringLiteral( "referer" ) ).toString().isEmpty() )
486 {
487 dsUri.setParam( QStringLiteral( "referer" ), parts.value( QStringLiteral( "referer" ) ).toString() );
488 }
489
491 parts.value( QStringLiteral( "entity" ) ).toString() );
492 if ( entity == Qgis::SensorThingsEntity::Invalid )
493 entity = QgsSensorThingsUtils::stringToEntity( parts.value( QStringLiteral( "entity" ) ).toString() );
494
495 if ( entity != Qgis::SensorThingsEntity::Invalid )
496 {
497 dsUri.setParam( QStringLiteral( "entity" ),
498 qgsEnumValueToKey( entity ) );
499 }
500
501 const QVariantList expandToParam = parts.value( QStringLiteral( "expandTo" ) ).toList();
502 if ( !expandToParam.isEmpty() )
503 {
504 QStringList expandToStringList;
505 for ( const QVariant &expansion : expandToParam )
506 {
507 const QgsSensorThingsExpansionDefinition expansionDefinition = expansion.value< QgsSensorThingsExpansionDefinition >();
508 if ( !expansionDefinition.isValid() )
509 continue;
510
511 expandToStringList.append( expansionDefinition.toString() );
512 }
513 if ( !expandToStringList.isEmpty() )
514 {
515 dsUri.setParam( QStringLiteral( "expandTo" ), expandToStringList.join( ';' ) );
516 }
517 }
518
519 bool ok = false;
520 const int maxPageSizeParam = parts.value( QStringLiteral( "pageSize" ) ).toInt( &ok );
521 if ( ok )
522 {
523 dsUri.setParam( QStringLiteral( "pageSize" ), QString::number( maxPageSizeParam ) );
524 }
525
526 ok = false;
527 const int featureLimitParam = parts.value( QStringLiteral( "featureLimit" ) ).toInt( &ok );
528 if ( ok )
529 {
530 dsUri.setParam( QStringLiteral( "featureLimit" ), QString::number( featureLimitParam ) );
531 }
532
533 const QString geometryType = parts.value( QStringLiteral( "geometryType" ) ).toString();
534 if ( geometryType.compare( QLatin1String( "point" ), Qt::CaseInsensitive ) == 0 )
535 {
537 }
538 else if ( geometryType.compare( QLatin1String( "multipoint" ), Qt::CaseInsensitive ) == 0 )
539 {
541 }
542 else if ( geometryType.compare( QLatin1String( "line" ), Qt::CaseInsensitive ) == 0 )
543 {
545 }
546 else if ( geometryType.compare( QLatin1String( "polygon" ), Qt::CaseInsensitive ) == 0 )
547 {
549 }
550
551 if ( parts.contains( QStringLiteral( "bounds" ) ) && parts.value( QStringLiteral( "bounds" ) ).userType() == qMetaTypeId<QgsRectangle>() )
552 {
553 const QgsRectangle bBox = parts.value( QStringLiteral( "bounds" ) ).value< QgsRectangle >();
554 dsUri.setParam( QStringLiteral( "bbox" ), QStringLiteral( "%1,%2,%3,%4" ).arg( bBox.xMinimum() ).arg( bBox.yMinimum() ).arg( bBox.xMaximum() ).arg( bBox.yMaximum() ) );
555 }
556
557 if ( !parts.value( QStringLiteral( "sql" ) ).toString().isEmpty() )
558 dsUri.setSql( parts.value( QStringLiteral( "sql" ) ).toString() );
559
560 return dsUri.uri( false );
561}
562
563QgsSensorThingsProvider *QgsSensorThingsProviderMetadata::createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags )
564{
565 return new QgsSensorThingsProvider( uri, options, flags );
566}
567
568QList<Qgis::LayerType> QgsSensorThingsProviderMetadata::supportedLayerTypes() const
569{
570 return { Qgis::LayerType::Vector };
571}
572
573QMap<QString, QgsAbstractProviderConnection *> QgsSensorThingsProviderMetadata::connections( bool cached )
574{
575 return connectionsProtected<QgsSensorThingsProviderConnection, QgsSensorThingsProviderConnection>( cached );
576}
577
578QgsAbstractProviderConnection *QgsSensorThingsProviderMetadata::createConnection( const QString &name )
579{
580 return new QgsSensorThingsProviderConnection( name );
581}
582
583void QgsSensorThingsProviderMetadata::deleteConnection( const QString &name )
584{
585 deleteConnectionProtected<QgsSensorThingsProviderConnection>( name );
586}
587
588void QgsSensorThingsProviderMetadata::saveConnection( const QgsAbstractProviderConnection *connection, const QString &name )
589{
590 saveConnectionProtected( connection, name );
591}
592
@ SelectAtId
Fast access to features using their ID.
Definition qgis.h:507
@ ReloadData
Provider is able to force reload data.
Definition qgis.h:523
@ ReadLayerMetadata
Provider can read layer metadata from data store. Since QGIS 3.0. See QgsDataProvider::layerMetadata(...
Definition qgis.h:518
QFlags< DataProviderFlag > DataProviderFlags
Data provider flags.
Definition qgis.h:2315
@ FastExtent2D
Provider's 2D extent retrieval via QgsDataProvider::extent() is always guaranteed to be trivial/fast ...
Definition qgis.h:2310
SensorThingsEntity
OGC SensorThings API entity types.
Definition qgis.h:5966
@ Sensor
A Sensor is an instrument that observes a property or phenomenon with the goal of producing an estima...
Definition qgis.h:5972
@ MultiDatastream
A MultiDatastream groups a collection of Observations and the Observations in a MultiDatastream have ...
Definition qgis.h:5976
@ ObservedProperty
An ObservedProperty specifies the phenomenon of an Observation.
Definition qgis.h:5973
@ Invalid
An invalid/unknown entity.
Definition qgis.h:5967
@ FeatureOfInterest
In the context of the Internet of Things, many Observations’ FeatureOfInterest can be the Location of...
Definition qgis.h:5975
@ Datastream
A Datastream groups a collection of Observations measuring the same ObservedProperty and produced by ...
Definition qgis.h:5971
@ Observation
An Observation is the act of measuring or otherwise determining the value of a property.
Definition qgis.h:5974
@ Location
A Location entity locates the Thing or the Things it associated with. A Thing’s Location entity is de...
Definition qgis.h:5969
@ Thing
A Thing is an object of the physical world (physical things) or the information world (virtual things...
Definition qgis.h:5968
@ HistoricalLocation
A Thing’s HistoricalLocation entity set provides the times of the current (i.e., last known) and prev...
Definition qgis.h:5970
@ Point
Points.
Definition qgis.h:359
@ Line
Lines.
Definition qgis.h:360
@ Polygon
Polygons.
Definition qgis.h:361
@ Unknown
Unknown types.
Definition qgis.h:362
@ Null
No geometry.
Definition qgis.h:363
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:486
QFlags< VectorProviderCapability > VectorProviderCapabilities
Vector data provider capabilities.
Definition qgis.h:536
@ Vector
Vector layer.
Definition qgis.h:191
@ SkipFeatureCount
Make featureCount() return -1 to indicate unknown, and subLayers() to return a unknown feature count ...
Definition qgis.h:469
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:277
@ MultiPointZ
MultiPointZ.
Definition qgis.h:299
@ PointZ
PointZ.
Definition qgis.h:295
@ MultiLineStringZ
MultiLineStringZ.
Definition qgis.h:300
@ MultiPolygonZ
MultiPolygonZ.
Definition qgis.h:301
Base class that can be used for any class that is capable of returning features.
An interface for data provider connections.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
A thread safe class for performing blocking (sync) network requests, with full support for QGIS proxy...
QString errorMessage() const
Returns the error message string, after a get(), post(), head() or put() request has been made.
@ NetworkError
A network error occurred.
@ ServerExceptionError
An exception was raised by the server.
@ NoError
No error was encountered.
@ TimeoutError
Timeout was reached before a reply was received.
QgsNetworkReplyContent reply() const
Returns the content of the network reply, after a get(), post(), head() or put() request has been mad...
Represents a coordinate reference system (CRS).
virtual void setDataSourceUri(const QString &uri)
Set the data source specification.
Stores the component parts of a data source URI (e.g.
void setSql(const QString &sql)
Sets the sql filter for the URI.
void setAuthConfigId(const QString &authcfg)
Sets the authentication configuration ID for the URI.
QString uri(bool expandAuthConfig=true) const
Returns the complete URI as a string.
void setUsername(const QString &username)
Sets the username for the URI.
QString param(const QString &key) const
Returns a generic parameter value corresponding to the specified key.
QString username() const
Returns the username stored in the URI.
Qgis::WkbType wkbType() const
Returns the WKB type associated with the URI.
void setWkbType(Qgis::WkbType type)
Sets the WKB type associated with the URI.
void setParam(const QString &key, const QString &value)
Sets a generic parameter value on the URI.
QString password() const
Returns the password stored in the URI.
QString authConfigId() const
Returns any associated authentication configuration ID stored in the URI.
QString sql() const
Returns the SQL filter stored in the URI, if set.
void setPassword(const QString &password)
Sets the password for the URI.
Represents a single error message.
Definition qgserror.h:33
Wrapper for iterator of features from vector data provider or vector layer.
Wraps a request for features to a vector layer (or directly its vector data provider).
Container of fields for a vector layer.
Definition qgsfields.h:46
A structured metadata store for a map layer.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE())
Adds a message to the log instance (and creates it if necessary).
Encapsulates a network reply within a container which is inexpensive to copy and safe to pass between...
QByteArray content() const
Returns the reply content.
Holds data provider key, description, and associated shared library file or function pointer informat...
A convenience class that simplifies locking and unlocking QReadWriteLocks.
A rectangle specified with double values.
double xMinimum
double yMinimum
double xMaximum
void setYMinimum(double y)
Set the minimum y value.
void setXMinimum(double x)
Set the minimum x value.
void setYMaximum(double y)
Set the maximum y value.
void setXMaximum(double x)
Set the maximum x value.
double yMaximum
Encapsulates information about how relationships in a SensorThings API service should be expanded.
static QgsSensorThingsExpansionDefinition fromString(const QString &string)
Returns a QgsSensorThingsExpansionDefinition from a string representation.
QString toString() const
Returns a string encapsulation of the expansion definition.
bool isValid() const
Returns true if the definition is valid.
Represents connections to SensorThings data sources.
static Qgis::SensorThingsEntity stringToEntity(const QString &type)
Converts a string value to a Qgis::SensorThingsEntity type.
static Qgis::SensorThingsEntity entitySetStringToEntity(const QString &type)
Converts a string value corresponding to a SensorThings entity set to a Qgis::SensorThingsEntity type...
Base class for vector data providers.
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...
static Q_INVOKABLE bool isMultiType(Qgis::WkbType type)
Returns true if the WKB type is a multi type.
@ UnknownCount
Provider returned an unknown feature count.
Definition qgis.h:547
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
Definition qgis.h:6798
#define QgsSetRequestInitiatorClass(request, _class)
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS
Setting options for creating vector data providers.