26#include <QCryptographicHash>
28#include <nlohmann/json.hpp>
32QgsSensorThingsSharedData::QgsSensorThingsSharedData(
const QString &uri )
34 const QVariantMap uriParts = QgsSensorThingsProviderMetadata().decodeUri( uri );
37 const QVariantList expandTo = uriParts.value( QStringLiteral(
"expandTo" ) ).toList();
38 QList< Qgis::SensorThingsEntity > expandedEntities;
39 for (
const QVariant &expansionVariant : expandTo )
44 mExpansions.append( expansion );
55 mMaximumPageSize = uriParts.value( QStringLiteral(
"pageSize" ), mMaximumPageSize ).toInt();
57 mFeatureLimit = uriParts.value( QStringLiteral(
"featureLimit" ) ).toInt();
58 mFilterExtent = uriParts.value( QStringLiteral(
"bounds" ) ).value<
QgsRectangle >();
59 mSubsetString = uriParts.value( QStringLiteral(
"sql" ) ).toString();
63 if ( uriParts.contains( QStringLiteral(
"geometryType" ) ) )
65 const QString geometryType = uriParts.value( QStringLiteral(
"geometryType" ) ).toString();
66 if ( geometryType.compare( QLatin1String(
"point" ), Qt::CaseInsensitive ) == 0 )
70 else if ( geometryType.compare( QLatin1String(
"multipoint" ), Qt::CaseInsensitive ) == 0 )
74 else if ( geometryType.compare( QLatin1String(
"line" ), Qt::CaseInsensitive ) == 0 )
78 else if ( geometryType.compare( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) == 0 )
104 mRootUri = uriParts.value( QStringLiteral(
"url" ) ).toString();
107QUrl QgsSensorThingsSharedData::parseUrl(
const QUrl &url,
bool *isTestEndpoint )
109 if ( isTestEndpoint )
110 *isTestEndpoint =
false;
112 QUrl modifiedUrl( url );
113 if ( modifiedUrl.toString().contains( QLatin1String(
"fake_qgis_http_endpoint" ) ) )
115 if ( isTestEndpoint )
116 *isTestEndpoint =
true;
119 QString modifiedUrlString = modifiedUrl.toString();
121 modifiedUrlString = QUrl::fromPercentEncoding( modifiedUrlString.toUtf8() );
122 modifiedUrlString.replace( QLatin1String(
"fake_qgis_http_endpoint/" ), QLatin1String(
"fake_qgis_http_endpoint_" ) );
124 modifiedUrlString = modifiedUrlString.mid( QStringLiteral(
"http://" ).size() );
125 QString args = modifiedUrlString.indexOf(
'?' ) >= 0 ? modifiedUrlString.mid( modifiedUrlString.indexOf(
'?' ) ) : QString();
126 if ( modifiedUrlString.size() > 150 )
128 args = QCryptographicHash::hash( args.toUtf8(), QCryptographicHash::Md5 ).toHex();
132 args.replace( QLatin1String(
"?" ), QLatin1String(
"_" ) );
133 args.replace( QLatin1String(
"&" ), QLatin1String(
"_" ) );
134 args.replace( QLatin1String(
"$" ), QLatin1String(
"_" ) );
135 args.replace( QLatin1String(
"<" ), QLatin1String(
"_" ) );
136 args.replace( QLatin1String(
">" ), QLatin1String(
"_" ) );
137 args.replace( QLatin1String(
"'" ), QLatin1String(
"_" ) );
138 args.replace( QLatin1String(
"\"" ), QLatin1String(
"_" ) );
139 args.replace( QLatin1String(
" " ), QLatin1String(
"_" ) );
140 args.replace( QLatin1String(
":" ), QLatin1String(
"_" ) );
141 args.replace( QLatin1String(
"/" ), QLatin1String(
"_" ) );
142 args.replace( QLatin1String(
"\n" ), QLatin1String(
"_" ) );
147 if ( modifiedUrlString[1] ==
'/' )
149 modifiedUrlString = modifiedUrlString[0] +
":/" + modifiedUrlString.mid( 2 );
152 modifiedUrlString = modifiedUrlString.mid( 0, modifiedUrlString.indexOf(
'?' ) ) + args;
153 QgsDebugMsgLevel( QStringLiteral(
"Get %1 (after laundering)" ).arg( modifiedUrlString ), 2 );
154 modifiedUrl = QUrl::fromLocalFile( modifiedUrlString );
155 if ( !QFile::exists( modifiedUrlString ) )
157 QgsDebugError( QStringLiteral(
"Local test file %1 for URL %2 does not exist!!!" ).arg( modifiedUrlString, url.toString() ) );
170 return hasCachedAllFeatures() ? mFetchedFeatureExtent
171 : ( !mFilterExtent.isNull() ? mFilterExtent :
QgsRectangle( -180, -90, 180, 90 ) );
174long long QgsSensorThingsSharedData::featureCount(
QgsFeedback *feedback )
const
177 if ( mFeatureCount >= 0 )
178 return mFeatureCount;
186 if ( !mExpansions.isEmpty() )
192 QString countUri = QStringLiteral(
"%1?$top=0&$count=true" ).arg( mEntityBaseUri );
196 if ( !filterString.isEmpty() )
197 filterString = QStringLiteral(
"&$filter=" ) + filterString;
198 if ( !filterString.isEmpty() )
199 countUri += filterString;
201 const QUrl url = parseUrl( QUrl( countUri ) );
203 QNetworkRequest request( url );
205 mHeaders.updateNetworkRequest( request );
212 return mFeatureCount;
225 auto rootContent = json::parse( content.
content().toStdString() );
226 if ( !rootContent.contains(
"@iot.count" ) )
228 mError = QObject::tr(
"No '@iot.count' value in response" );
229 return mFeatureCount;
232 mFeatureCount = rootContent[
"@iot.count"].get<
long long>();
233 if ( mFeatureLimit > 0 && mFeatureCount > mFeatureLimit )
234 mFeatureCount = mFeatureLimit;
236 catch (
const json::parse_error &ex )
238 mError = QObject::tr(
"Error parsing response: %1" ).arg( ex.what() );
242 return mFeatureCount;
245QString QgsSensorThingsSharedData::subsetString()
const
247 return mSubsetString;
250bool QgsSensorThingsSharedData::hasCachedAllFeatures()
const
253 return mHasCachedAllFeatures
254 || ( mFeatureCount > 0 && mCachedFeatures.size() == mFeatureCount )
255 || ( mFeatureLimit > 0 && mRetrievedBaseFeatureCount >= mFeatureLimit );
263 QMap<QgsFeatureId, QgsFeature>::const_iterator it = mCachedFeatures.constFind(
id );
264 if ( it != mCachedFeatures.constEnd() )
270 if ( hasCachedAllFeatures() )
273 bool featureFetched =
false;
275 if ( mNextPage.isEmpty() )
279 int thisPageSize = mMaximumPageSize;
280 if ( mFeatureLimit > 0 && ( mCachedFeatures.size() + thisPageSize ) > mFeatureLimit )
281 thisPageSize = mFeatureLimit - mCachedFeatures.size();
283 mNextPage = QStringLiteral(
"%1?$top=%2&$count=false%3" ).arg( mEntityBaseUri ).arg( thisPageSize ).arg( !mExpandQueryString.isEmpty() ? ( QStringLiteral(
"&" ) + mExpandQueryString ) : QString() );
287 if ( !filterString.isEmpty() )
288 mNextPage += QStringLiteral(
"&$filter=" ) + filterString;
293 processFeatureRequest( mNextPage, feedback, [
id, &f, &featureFetched](
const QgsFeature & feature )
295 if ( feature.
id() ==
id )
298 featureFetched = true;
301 }, [&featureFetched,
this]
303 return !featureFetched && !hasCachedAllFeatures();
307 mHasCachedAllFeatures =
true;
310 return featureFetched;
319 if ( hasCachedAllFeatures() || mCachedExtent.contains( extentGeom ) )
323 return qgis::listToSet( mSpatialIndex.intersects( requestExtent ) );
329 if ( !filterString.isEmpty() )
330 filterString = QStringLiteral(
"&$filter=" ) + filterString;
331 int thisPageSize = mMaximumPageSize;
333 if ( !thisPage.isEmpty() )
336 const thread_local QRegularExpression topRe( QStringLiteral(
"\\$top=\\d+" ) );
337 const QRegularExpressionMatch match = topRe.match( queryUrl );
338 if ( match.hasMatch() )
340 if ( mFeatureLimit > 0 && ( mCachedFeatures.size() + thisPageSize ) > mFeatureLimit )
341 thisPageSize = mFeatureLimit - mCachedFeatures.size();
342 queryUrl = queryUrl.left( match.capturedStart( 0 ) ) + QStringLiteral(
"$top=%1" ).arg( thisPageSize ) + queryUrl.mid( match.capturedEnd( 0 ) );
347 queryUrl = QStringLiteral(
"%1?$top=%2&$count=false%3%4" ).arg( mEntityBaseUri ).arg( thisPageSize ).arg( filterString, !mExpandQueryString.isEmpty() ? ( QStringLiteral(
"&" ) + mExpandQueryString ) : QString() );
350 if ( thisPage.isEmpty() && mCachedExtent.intersects( extentGeom ) )
356 return qgis::listToSet( mSpatialIndex.intersects( requestExtent ) );
363 bool noMoreFeatures =
false;
364 bool hasFirstPage =
false;
365 const bool res = processFeatureRequest( queryUrl, feedback, [&ids, &alreadyFetchedIds](
const QgsFeature & feature )
367 if ( !alreadyFetchedIds.contains( feature.
id() ) )
368 ids.insert( feature.
id() );
380 noMoreFeatures =
true;
382 if ( noMoreFeatures && res && ( !feedback || !feedback->
isCanceled() ) )
387 nextPage = noMoreFeatures || !res ? QString() : queryUrl;
392void QgsSensorThingsSharedData::clearCache()
397 mCachedFeatures.clear();
398 mIotIdToFeatureId.clear();
403bool QgsSensorThingsSharedData::processFeatureRequest( QString &nextPage,
QgsFeedback *feedback,
const std::function<
void(
const QgsFeature & ) > &fetchedFeatureCallback,
const std::function<
bool ()> &continueFetchingCallback,
const std::function<
void ()> &onNoMoreFeaturesCallback )
408 const QString authcfg = mAuthCfg;
411 const QList< QgsSensorThingsExpansionDefinition > expansions = mExpansions;
413 while ( continueFetchingCallback() )
422 const QUrl url = parseUrl( nextPage );
424 QNetworkRequest request( url );
449 const auto rootContent = json::parse( content.
content().toStdString() );
450 if ( !rootContent.contains(
"value" ) )
453 mError = QObject::tr(
"No 'value' in response" );
460 const auto &values = rootContent[
"value"];
461 if ( values.empty() )
465 onNoMoreFeaturesCallback();
472 for (
const auto &featureData : values )
474 auto getString = [](
const basic_json<> &json,
const char *tag ) -> QVariant
476 if ( !json.contains( tag ) )
479 std::function< QString(
const basic_json<> &obj,
bool &ok ) > objToString;
480 objToString = [&objToString](
const basic_json<> &obj,
bool & ok ) -> QString
483 if ( obj.is_number_integer() )
485 return QString::number( obj.get<
int>() );
487 else if ( obj.is_number_unsigned() )
489 return QString::number( obj.get<
unsigned>() );
491 else if ( obj.is_boolean() )
493 return QString::number( obj.get<
bool>() );
495 else if ( obj.is_number_float() )
497 return QString::number( obj.get<
double>() );
499 else if ( obj.is_array() )
502 results.reserve( obj.size() );
503 for (
const auto &item : obj )
506 const QString itemString = objToString( item, itemOk );
508 results.push_back( itemString );
510 return results.join(
',' );
512 else if ( obj.is_string() )
514 return QString::fromStdString( obj.get<std::string >() );
521 const auto &jObj = json[tag];
523 const QString r = objToString( jObj, ok );
529 auto getDateTime = [](
const basic_json<> &json,
const char *tag ) -> QVariant
531 if ( !json.contains( tag ) )
534 const auto &jObj = json[tag];
535 if ( jObj.is_string() )
537 const QString dateTimeString = QString::fromStdString( json[tag].get<std::string >() );
538 return QDateTime::fromString( dateTimeString, Qt::ISODateWithMs );
544 auto getVariantMap = [](
const basic_json<> &json,
const char *tag ) -> QVariant
546 if ( !json.contains( tag ) )
552 auto getVariantList = [](
const basic_json<> &json,
const char *tag ) -> QVariant
554 if ( !json.contains( tag ) )
560 auto getStringList = [](
const basic_json<> &json,
const char *tag ) -> QVariant
562 if ( !json.contains( tag ) )
565 const auto &jObj = json[tag];
566 if ( jObj.is_string() )
568 return QStringList{ QString::fromStdString( json[tag].get<std::string >() ) };
570 else if ( jObj.is_array() )
573 for (
const auto &element : jObj )
575 if ( element.is_string() )
576 res.append( QString::fromStdString( element.get<std::string >() ) );
584 auto getDateTimeRange = [](
const basic_json<> &json,
const char *tag,
bool allowInstant = false ) -> std::pair< QVariant, QVariant >
586 if ( !json.contains( tag ) )
587 return { QVariant(), QVariant() };
589 const auto &jObj = json[tag];
590 if ( jObj.is_string() )
592 const QString rangeString = QString::fromStdString( json[tag].get<std::string >() );
593 const QStringList rangeParts = rangeString.split(
'/' );
594 if ( rangeParts.size() == 2 )
598 QDateTime::fromString( rangeParts.at( 0 ), Qt::ISODateWithMs ),
599 QDateTime::fromString( rangeParts.at( 1 ), Qt::ISODateWithMs )
602 else if ( allowInstant )
604 const QDateTime instant = QDateTime::fromString( rangeString, Qt::ISODateWithMs );
605 return { instant, instant };
609 return { QVariant(), QVariant() };
612 const QString iotId = getString( featureData,
"@iot.id" ).toString();
613 if ( expansions.isEmpty() )
615 auto existingFeatureIdIt = mIotIdToFeatureId.constFind( iotId );
616 if ( existingFeatureIdIt != mIotIdToFeatureId.constEnd() )
619 fetchedFeatureCallback( *mCachedFeatures.find( *existingFeatureIdIt ) );
629 if ( featureData.contains( mGeometryField.toLocal8Bit().constData() ) )
631 const auto &geometryPart = featureData[mGeometryField.toLocal8Bit().constData()];
632 if ( geometryPart.contains(
"geometry" ) )
639 auto extendAttributes = [&getString, &getVariantMap, &getDateTimeRange, &getDateTime, &getStringList, &getVariantList](
Qgis::SensorThingsEntity entityType,
const auto & entityData,
QgsAttributes & attributes )
641 const QString iotId = getString( entityData,
"@iot.id" ).toString();
642 const QString selfLink = getString( entityData,
"@iot.selfLink" ).toString();
644 const QVariant properties = getVariantMap( entityData,
"properties" );
647 switch ( entityType )
656 << getString( entityData,
"name" )
657 << getString( entityData,
"description" )
665 << getString( entityData,
"name" )
666 << getString( entityData,
"description" )
674 << getDateTime( entityData,
"time" );
679 std::pair< QVariant, QVariant > phenomenonTime = getDateTimeRange( entityData,
"phenomenonTime",
true );
680 std::pair< QVariant, QVariant > resultTime = getDateTimeRange( entityData,
"resultTime" );
684 << getString( entityData,
"name" )
685 << getString( entityData,
"description" )
686 << getVariantMap( entityData,
"unitOfMeasurement" )
687 << getString( entityData,
"observationType" )
689 << phenomenonTime.first
690 << phenomenonTime.second
692 << resultTime.second;
700 << getString( entityData,
"name" )
701 << getString( entityData,
"description" )
702 << getString( entityData,
"metadata" )
710 << getString( entityData,
"name" )
711 << getString( entityData,
"definition" )
712 << getString( entityData,
"description" )
718 std::pair< QVariant, QVariant > phenomenonTime = getDateTimeRange( entityData,
"phenomenonTime" );
719 std::pair< QVariant, QVariant > validTime = getDateTimeRange( entityData,
"validTime" );
723 << phenomenonTime.first
724 << phenomenonTime.second
725 << getString( entityData,
"result" )
726 << getDateTime( entityData,
"resultTime" )
727 << getStringList( entityData,
"resultQuality" )
730 << getVariantMap( entityData,
"parameters" );
738 << getString( entityData,
"name" )
739 << getString( entityData,
"description" )
745 std::pair< QVariant, QVariant > phenomenonTime = getDateTimeRange( entityData,
"phenomenonTime" );
746 std::pair< QVariant, QVariant > resultTime = getDateTimeRange( entityData,
"resultTime" );
750 << getString( entityData,
"name" )
751 << getString( entityData,
"description" )
752 << getVariantList( entityData,
"unitOfMeasurements" )
753 << getString( entityData,
"observationType" )
754 << getStringList( entityData,
"multiObservationDataTypes" )
756 << phenomenonTime.first
757 << phenomenonTime.second
759 << resultTime.second;
767 attributes.reserve( fields.
size() );
768 extendAttributes( mEntityType, featureData, attributes );
770 auto processFeature = [
this, &fetchedFeatureCallback](
QgsFeature & feature,
const QString & rawFeatureId )
772 feature.
setId( mNextFeatureId++ );
774 mCachedFeatures.insert( feature.
id(), feature );
775 mIotIdToFeatureId.insert( rawFeatureId, feature.
id() );
776 mSpatialIndex.addFeature( feature );
779 fetchedFeatureCallback( feature );
782 const QString baseFeatureId = getString( featureData,
"@iot.id" ).toString();
783 if ( !expansions.empty() )
785 mRetrievedBaseFeatureCount++;
787 std::function< void(
const nlohmann::json &,
Qgis::SensorThingsEntity,
const QList<QgsSensorThingsExpansionDefinition > &,
const QString &,
const QgsAttributes & ) > traverseExpansion;
788 traverseExpansion = [
this, &feature, &getString, &traverseExpansion, &fetchedFeatureCallback, &extendAttributes, &processFeature](
const nlohmann::json & currentLevelData,
Qgis::SensorThingsEntity parentEntityType,
const QList<QgsSensorThingsExpansionDefinition > &expansionTargets,
const QString & lowerLevelId,
const QgsAttributes & lowerLevelAttributes )
791 const QList< QgsSensorThingsExpansionDefinition > remainingExpansionTargets = expansionTargets.mid( 1 );
795 QString currentExpansionPropertyString;
796 switch ( cardinality )
809 if ( currentLevelData.contains( currentExpansionPropertyString.toLocal8Bit().constData() ) )
811 auto parseExpandedEntity = [lowerLevelAttributes, &feature, &processFeature, &lowerLevelId, &getString, &remainingExpansionTargets, &fetchedFeatureCallback, &extendAttributes, &traverseExpansion, ¤tExpansionTarget,
this](
const json & expandedEntityElement )
814 const QString expandedEntityIotId = getString( expandedEntityElement,
"@iot.id" ).toString();
815 const QString expandedFeatureId = lowerLevelId +
'_' + expandedEntityIotId;
817 if ( remainingExpansionTargets.empty() )
819 auto existingFeatureIdIt = mIotIdToFeatureId.constFind( expandedFeatureId );
820 if ( existingFeatureIdIt != mIotIdToFeatureId.constEnd() )
823 fetchedFeatureCallback( *mCachedFeatures.find( *existingFeatureIdIt ) );
828 extendAttributes( currentExpansionTarget.childEntity(), expandedEntityElement, expandedAttributes );
829 if ( !remainingExpansionTargets.empty() )
832 traverseExpansion( expandedEntityElement, currentExpansionTarget.childEntity(), remainingExpansionTargets, expandedFeatureId, expandedAttributes );
836 feature.setAttributes( expandedAttributes );
837 processFeature( feature, expandedFeatureId );
840 const auto &expandedEntity = currentLevelData[currentExpansionPropertyString.toLocal8Bit().constData()];
841 if ( expandedEntity.is_array() )
843 for (
const auto &expandedEntityElement : expandedEntity )
845 parseExpandedEntity( expandedEntityElement );
851 else if ( expandedEntity.is_object() )
853 parseExpandedEntity( expandedEntity );
864 traverseExpansion( featureData, mEntityType, expansions, baseFeatureId, attributes );
866 if ( mFeatureLimit > 0 && mFeatureLimit <= mRetrievedBaseFeatureCount )
871 feature.setAttributes( attributes );
872 processFeature( feature, baseFeatureId );
873 mRetrievedBaseFeatureCount++;
874 if ( mFeatureLimit > 0 && mFeatureLimit <= mRetrievedBaseFeatureCount )
881 if ( rootContent.contains(
"@iot.nextLink" ) && ( mFeatureLimit == 0 || mFeatureLimit > mCachedFeatures.size() ) )
883 nextPage = QString::fromStdString( rootContent[
"@iot.nextLink"].get<std::string>() );
887 onNoMoreFeaturesCallback();
891 if ( !continueFetchingCallback() )
897 catch (
const json::parse_error &ex )
900 mError = QObject::tr(
"Error parsing response: %1" ).arg( ex.what() );
901 QgsDebugMsgLevel( QStringLiteral(
"Error parsing response: %1" ).arg( ex.what() ), 2 );
SensorThingsEntity
OGC SensorThings API entity types.
@ Sensor
A Sensor is an instrument that observes a property or phenomenon with the goal of producing an estima...
@ MultiDatastream
A MultiDatastream groups a collection of Observations and the Observations in a MultiDatastream have ...
@ ObservedProperty
An ObservedProperty specifies the phenomenon of an Observation.
@ Invalid
An invalid/unknown entity.
@ FeatureOfInterest
In the context of the Internet of Things, many Observations’ FeatureOfInterest can be the Location of...
@ Datastream
A Datastream groups a collection of Observations measuring the same ObservedProperty and produced by ...
@ Observation
An Observation is the act of measuring or otherwise determining the value of a property.
@ Location
A Location entity locates the Thing or the Things it associated with. A Thing’s Location entity is de...
@ Thing
A Thing is an object of the physical world (physical things) or the information world (virtual things...
@ HistoricalLocation
A Thing’s HistoricalLocation entity set provides the times of the current (i.e., last known) and prev...
RelationshipCardinality
Relationship cardinality.
@ ManyToMany
Many to many relationship.
@ ManyToOne
Many to one relationship.
@ OneToOne
One to one relationship.
@ OneToMany
One to many relationship.
@ MultiPointZ
MultiPointZ.
@ MultiLineStringZ
MultiLineStringZ.
@ MultiPolygonZ
MultiPolygonZ.
A thread safe class for performing blocking (sync) network requests, with full support for QGIS proxy...
ErrorCode get(QNetworkRequest &request, bool forceRefresh=false, QgsFeedback *feedback=nullptr)
Performs a "get" operation on the specified request.
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.
@ 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).
Class for storing the component parts of a RDBMS data source URI (e.g.
void setEncodedUri(const QByteArray &uri)
Sets the complete encoded uri.
QgsHttpHeaders httpHeaders() const
Returns http headers.
QString authConfigId() const
Returns any associated authentication configuration ID stored in the URI.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
void setId(QgsFeatureId id)
Sets the feature id for this feature.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
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.
Container of fields for a vector layer.
int size() const
Returns number of items.
A geometry is the spatial representation of a feature.
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
static QgsGeometry unaryUnion(const QVector< QgsGeometry > &geometries, const QgsGeometryParameters ¶meters=QgsGeometryParameters())
Compute the unary union on a list of geometries.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
static QgsGeometry geometryFromGeoJson(const json &geometry)
Parses a GeoJSON "geometry" value to a QgsGeometry object.
static QVariant jsonToVariant(const json &value)
Converts a JSON value to a QVariant, in case of parsing error an invalid QVariant is returned.
Encapsulates a network reply within a container which is inexpensive to copy and safe to pass between...
QByteArray content() const
Returns the reply content.
The QgsReadWriteLocker class is a convenience class that simplifies locking and unlocking QReadWriteL...
A rectangle specified with double values.
bool isNull() const
Test if the rectangle is null (holding no spatial information).
QgsRectangle intersect(const QgsRectangle &rect) const
Returns the intersection with the given rectangle.
Encapsulates information about how relationships in a SensorThings API service should be expanded.
Qgis::SensorThingsEntity childEntity() const
Returns the target child entity which should be expanded.
bool isValid() const
Returns true if the definition is valid.
static QString entityToSetString(Qgis::SensorThingsEntity type)
Converts a SensorThings entity set to a SensorThings entity set string.
static QString asQueryString(Qgis::SensorThingsEntity baseType, const QList< QgsSensorThingsExpansionDefinition > &expansions)
Returns a list of expansions as a valid SensorThings API query string, eg "$expand=Locations($orderby...
static QString combineFilters(const QStringList &filters)
Combines a set of SensorThings API filter operators.
static QString filterForWkbType(Qgis::SensorThingsEntity entityType, Qgis::WkbType wkbType)
Returns a filter string which restricts results to those matching the specified entityType and wkbTyp...
static Qgis::RelationshipCardinality relationshipCardinality(Qgis::SensorThingsEntity baseType, Qgis::SensorThingsEntity relatedType, bool &valid)
Returns the cardinality of the relationship between a base entity type and a related entity type.
static bool entityTypeHasGeometry(Qgis::SensorThingsEntity type)
Returns true if the specified entity type can have geometry attached.
static QgsFields fieldsForExpandedEntityType(Qgis::SensorThingsEntity baseType, const QList< Qgis::SensorThingsEntity > &expandedTypes)
Returns the fields which correspond to a specified entity baseType, expanded using the specified list...
static QString geometryFieldForEntityType(Qgis::SensorThingsEntity type)
Returns the geometry field for a specified entity type.
static QString filterForExtent(const QString &geometryField, const QgsRectangle &extent)
Returns a filter string which restricts results to those within the specified extent.
A spatial index for QgsFeature objects.
@ Uncounted
Feature count not yet computed.
@ UnknownCount
Provider returned an unknown feature count.
T qgsEnumKeyToValue(const QString &key, const T &defaultValue, bool tryValueAsKey=true, bool *returnOk=nullptr)
Returns the value corresponding to the given key of an enum.
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
QSet< QgsFeatureId > QgsFeatureIds
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
#define QgsSetRequestInitiatorClass(request, _class)