18#include <nlohmann/json.hpp>
29#include <QCryptographicHash>
33using namespace Qt::StringLiterals;
37QgsSensorThingsSharedData::QgsSensorThingsSharedData(
const QString &uri )
39 const QVariantMap uriParts = QgsSensorThingsProviderMetadata().decodeUri( uri );
42 const QVariantList expandTo = uriParts.value( u
"expandTo"_s ).toList();
43 QList< Qgis::SensorThingsEntity > expandedEntities;
44 for (
const QVariant &expansionVariant : expandTo )
49 mExpansions.append( expansion );
60 mMaximumPageSize = uriParts.value( u
"pageSize"_s, mMaximumPageSize ).toInt();
62 mFeatureLimit = uriParts.value( u
"featureLimit"_s ).toInt();
63 mFilterExtent = uriParts.value( u
"bounds"_s ).value<
QgsRectangle >();
64 mSubsetString = uriParts.value( u
"sql"_s ).
toString();
68 if ( uriParts.contains( u
"geometryType"_s ) )
70 const QString geometryType = uriParts.value( u
"geometryType"_s ).toString();
71 if ( geometryType.compare(
"point"_L1, Qt::CaseInsensitive ) == 0 )
75 else if ( geometryType.compare(
"multipoint"_L1, Qt::CaseInsensitive ) == 0 )
79 else if ( geometryType.compare(
"line"_L1, Qt::CaseInsensitive ) == 0 )
83 else if ( geometryType.compare(
"polygon"_L1, Qt::CaseInsensitive ) == 0 )
105 mAuthCfg = dsUri.authConfigId();
106 mHeaders = dsUri.httpHeaders();
108 mRootUri = uriParts.value( u
"url"_s ).toString();
111QUrl QgsSensorThingsSharedData::parseUrl(
const QUrl &url,
bool *isTestEndpoint )
113 if ( isTestEndpoint )
114 *isTestEndpoint =
false;
116 QUrl modifiedUrl( url );
117 if ( modifiedUrl.toString().contains(
"fake_qgis_http_endpoint"_L1 ) )
119 if ( isTestEndpoint )
120 *isTestEndpoint =
true;
123 QString modifiedUrlString = modifiedUrl.toString();
125 modifiedUrlString = QUrl::fromPercentEncoding( modifiedUrlString.toUtf8() );
126 modifiedUrlString.replace(
"fake_qgis_http_endpoint/"_L1,
"fake_qgis_http_endpoint_"_L1 );
128 modifiedUrlString = modifiedUrlString.mid( u
"http://"_s.size() );
129 QString args = modifiedUrlString.indexOf(
'?' ) >= 0 ? modifiedUrlString.mid( modifiedUrlString.indexOf(
'?' ) ) : QString();
130 if ( modifiedUrlString.size() > 150 )
132 args = QCryptographicHash::hash( args.toUtf8(), QCryptographicHash::Md5 ).toHex();
136 args.replace(
"?"_L1,
"_"_L1 );
137 args.replace(
"&"_L1,
"_"_L1 );
138 args.replace(
"$"_L1,
"_"_L1 );
139 args.replace(
"<"_L1,
"_"_L1 );
140 args.replace(
">"_L1,
"_"_L1 );
141 args.replace(
"'"_L1,
"_"_L1 );
142 args.replace(
"\""_L1,
"_"_L1 );
143 args.replace(
" "_L1,
"_"_L1 );
144 args.replace(
":"_L1,
"_"_L1 );
145 args.replace(
"/"_L1,
"_"_L1 );
146 args.replace(
"\n"_L1,
"_"_L1 );
151 if ( modifiedUrlString[1] ==
'/' )
153 modifiedUrlString = modifiedUrlString[0] +
":/" + modifiedUrlString.mid( 2 );
156 modifiedUrlString = modifiedUrlString.mid( 0, modifiedUrlString.indexOf(
'?' ) ) + args;
157 QgsDebugMsgLevel( u
"Get %1 (after laundering)"_s.arg( modifiedUrlString ), 2 );
158 modifiedUrl = QUrl::fromLocalFile( modifiedUrlString );
159 if ( !QFile::exists( modifiedUrlString ) )
161 QgsDebugError( u
"Local test file %1 for URL %2 does not exist!!!"_s.arg( modifiedUrlString, url.toString() ) );
174 return hasCachedAllFeatures() ? mFetchedFeatureExtent : ( !mFilterExtent.isNull() ? mFilterExtent :
QgsRectangle( -180, -90, 180, 90 ) );
177long long QgsSensorThingsSharedData::featureCount(
QgsFeedback *feedback )
const
180 if ( mFeatureCount >= 0 )
181 return mFeatureCount;
189 if ( !mExpansions.isEmpty() )
195 QString countUri = u
"%1?$top=0&$count=true"_s.arg( mEntityBaseUri );
199 if ( !filterString.isEmpty() )
200 filterString = u
"&$filter="_s + filterString;
201 if ( !filterString.isEmpty() )
202 countUri += filterString;
204 const QUrl url = parseUrl( QUrl( countUri ) );
206 QNetworkRequest request( url );
208 mHeaders.updateNetworkRequest( request );
215 return mFeatureCount;
228 auto rootContent = json::parse( content.
content().toStdString() );
229 if ( !rootContent.contains(
"@iot.count" ) )
231 mError = QObject::tr(
"No '@iot.count' value in response" );
232 return mFeatureCount;
235 mFeatureCount = rootContent[
"@iot.count"].get<
long long>();
236 if ( mFeatureLimit > 0 && mFeatureCount > mFeatureLimit )
237 mFeatureCount = mFeatureLimit;
239 catch (
const json::parse_error &ex )
241 mError = QObject::tr(
"Error parsing response: %1" ).arg( ex.what() );
245 return mFeatureCount;
248QString QgsSensorThingsSharedData::subsetString()
const
250 return mSubsetString;
253bool QgsSensorThingsSharedData::hasCachedAllFeatures()
const
256 return mHasCachedAllFeatures || ( mFeatureCount > 0 && mCachedFeatures.size() == mFeatureCount ) || ( mFeatureLimit > 0 && mRetrievedBaseFeatureCount >= mFeatureLimit );
264 QMap<QgsFeatureId, QgsFeature>::const_iterator it = mCachedFeatures.constFind(
id );
265 if ( it != mCachedFeatures.constEnd() )
271 if ( hasCachedAllFeatures() )
274 bool featureFetched =
false;
276 if ( mNextPage.isEmpty() )
280 int thisPageSize = mMaximumPageSize;
281 if ( mFeatureLimit > 0 && ( mCachedFeatures.size() + thisPageSize ) > mFeatureLimit )
282 thisPageSize = mFeatureLimit - mCachedFeatures.size();
284 mNextPage = u
"%1?$top=%2&$count=false%3"_s.arg( mEntityBaseUri ).arg( thisPageSize ).arg( !mExpandQueryString.isEmpty() ? ( u
"&"_s + mExpandQueryString ) : QString() );
288 if ( !filterString.isEmpty() )
289 mNextPage += u
"&$filter="_s + filterString;
294 processFeatureRequest(
297 [
id, &f, &featureFetched](
const QgsFeature &feature ) {
298 if ( feature.
id() ==
id )
301 featureFetched =
true;
305 [&featureFetched,
this] {
return !featureFetched && !hasCachedAllFeatures(); },
308 mHasCachedAllFeatures =
true;
312 return featureFetched;
321 if ( hasCachedAllFeatures() || mCachedExtent.contains( extentGeom ) )
325 return qgis::listToSet( mSpatialIndex.intersects( requestExtent ) );
331 if ( !filterString.isEmpty() )
332 filterString = u
"&$filter="_s + filterString;
333 int thisPageSize = mMaximumPageSize;
335 if ( !thisPage.isEmpty() )
338 const thread_local QRegularExpression topRe( u
"\\$top=\\d+"_s );
339 const QRegularExpressionMatch match = topRe.match( queryUrl );
340 if ( match.hasMatch() )
342 if ( mFeatureLimit > 0 && ( mCachedFeatures.size() + thisPageSize ) > mFeatureLimit )
343 thisPageSize = mFeatureLimit - mCachedFeatures.size();
344 queryUrl = queryUrl.left( match.capturedStart( 0 ) ) + u
"$top=%1"_s.arg( thisPageSize ) + queryUrl.mid( match.capturedEnd( 0 ) );
349 queryUrl = u
"%1?$top=%2&$count=false%3%4"_s.arg( mEntityBaseUri ).arg( thisPageSize ).arg( filterString, !mExpandQueryString.isEmpty() ? ( u
"&"_s + mExpandQueryString ) : QString() );
352 if ( thisPage.isEmpty() && mCachedExtent.intersects( extentGeom ) )
358 return qgis::listToSet( mSpatialIndex.intersects( requestExtent ) );
365 bool noMoreFeatures =
false;
366 bool hasFirstPage =
false;
367 const bool res = processFeatureRequest(
370 [&ids, &alreadyFetchedIds](
const QgsFeature &feature ) {
371 if ( !alreadyFetchedIds.contains( feature.
id() ) )
372 ids.insert( feature.
id() );
383 [&noMoreFeatures] { noMoreFeatures =
true; }
385 if ( noMoreFeatures && res && ( !feedback || !feedback->
isCanceled() ) )
390 nextPage = noMoreFeatures || !res ? QString() : queryUrl;
395void QgsSensorThingsSharedData::clearCache()
400 mCachedFeatures.clear();
401 mIotIdToFeatureId.clear();
406bool QgsSensorThingsSharedData::processFeatureRequest(
409 const std::function<
void(
const QgsFeature & ) > &fetchedFeatureCallback,
410 const std::function<
bool()> &continueFetchingCallback,
411 const std::function<
void()> &onNoMoreFeaturesCallback
417 const QString authcfg = mAuthCfg;
420 const QList< QgsSensorThingsExpansionDefinition > expansions = mExpansions;
422 while ( continueFetchingCallback() )
431 const QUrl url = parseUrl( nextPage );
433 QNetworkRequest request( url );
458 const auto rootContent = json::parse( content.
content().toStdString() );
459 if ( !rootContent.contains(
"value" ) )
462 mError = QObject::tr(
"No 'value' in response" );
469 const auto &values = rootContent[
"value"];
470 if ( values.empty() )
474 onNoMoreFeaturesCallback();
481 for (
const auto &featureData : values )
483 auto getString = [](
const basic_json<> &json,
const char *tag ) -> QVariant {
484 if ( !json.contains( tag ) )
487 std::function< QString(
const basic_json<> &obj,
bool &ok ) > objToString;
488 objToString = [&objToString](
const basic_json<> &obj,
bool &ok ) -> QString {
490 if ( obj.is_number_integer() )
492 return QString::number( obj.get<
int>() );
494 else if ( obj.is_number_unsigned() )
496 return QString::number( obj.get<
unsigned>() );
498 else if ( obj.is_boolean() )
500 return QString::number( obj.get<
bool>() );
502 else if ( obj.is_number_float() )
504 return QString::number( obj.get<
double>() );
506 else if ( obj.is_array() )
509 results.reserve( obj.size() );
510 for (
const auto &item : obj )
513 const QString itemString = objToString( item, itemOk );
515 results.push_back( itemString );
517 return results.join(
',' );
519 else if ( obj.is_string() )
521 return QString::fromStdString( obj.get<std::string >() );
528 const auto &jObj = json[tag];
530 const QString r = objToString( jObj, ok );
536 auto getDateTime = [](
const basic_json<> &json,
const char *tag ) -> QVariant {
537 if ( !json.contains( tag ) )
540 const auto &jObj = json[tag];
541 if ( jObj.is_string() )
543 const QString dateTimeString = QString::fromStdString( json[tag].get<std::string >() );
544 return QDateTime::fromString( dateTimeString, Qt::ISODateWithMs );
550 auto getVariantMap = [](
const basic_json<> &json,
const char *tag ) -> QVariant {
551 if ( !json.contains( tag ) )
557 auto getVariantList = [](
const basic_json<> &json,
const char *tag ) -> QVariant {
558 if ( !json.contains( tag ) )
564 auto getStringList = [](
const basic_json<> &json,
const char *tag ) -> QVariant {
565 if ( !json.contains( tag ) )
568 const auto &jObj = json[tag];
569 if ( jObj.is_string() )
571 return QStringList { QString::fromStdString( json[tag].get<std::string >() ) };
573 else if ( jObj.is_array() )
576 for (
const auto &element : jObj )
578 if ( element.is_string() )
579 res.append( QString::fromStdString( element.get<std::string >() ) );
587 auto getDateTimeRange = [](
const basic_json<> &json,
const char *tag ) -> std::pair< QVariant, QVariant > {
588 if ( !json.contains( tag ) )
589 return { QVariant(), QVariant() };
591 const auto &jObj = json[tag];
592 if ( jObj.is_string() )
594 const QString rangeString = QString::fromStdString( json[tag].get<std::string >() );
595 const QStringList rangeParts = rangeString.split(
'/' );
596 if ( rangeParts.size() == 2 )
598 return { QDateTime::fromString( rangeParts.at( 0 ), Qt::ISODateWithMs ), QDateTime::fromString( rangeParts.at( 1 ), Qt::ISODateWithMs ) };
602 const QDateTime instant = QDateTime::fromString( rangeString, Qt::ISODateWithMs );
603 if ( instant.isValid() )
604 return { instant, instant };
608 return { QVariant(), QVariant() };
611 const QString iotId = getString( featureData,
"@iot.id" ).toString();
612 if ( expansions.isEmpty() )
614 auto existingFeatureIdIt = mIotIdToFeatureId.constFind( iotId );
615 if ( existingFeatureIdIt != mIotIdToFeatureId.constEnd() )
618 fetchedFeatureCallback( *mCachedFeatures.find( *existingFeatureIdIt ) );
628 if ( featureData.contains( mGeometryField.toLocal8Bit().constData() ) )
630 const auto &geometryPart = featureData[mGeometryField.toLocal8Bit().constData()];
631 if ( geometryPart.contains(
"geometry" ) )
638 auto extendAttributes =
639 [&getString, &getVariantMap, &getDateTimeRange, &getDateTime, &getStringList, &getVariantList](
Qgis::SensorThingsEntity entityType,
const auto &entityData,
QgsAttributes &attributes ) {
640 const QString iotId = getString( entityData,
"@iot.id" ).toString();
641 const QString selfLink = getString( entityData,
"@iot.selfLink" ).toString();
643 const QVariant properties = getVariantMap( entityData,
"properties" );
646 switch ( entityType )
652 attributes << iotId << selfLink << getString( entityData,
"name" ) << getString( entityData,
"description" ) << properties;
656 attributes << iotId << selfLink << getString( entityData,
"name" ) << getString( entityData,
"description" ) << properties;
660 attributes << iotId << selfLink << getDateTime( entityData,
"time" );
665 std::pair< QVariant, QVariant > phenomenonTime = getDateTimeRange( entityData,
"phenomenonTime" );
666 std::pair< QVariant, QVariant > resultTime = getDateTimeRange( entityData,
"resultTime" );
670 << getString( entityData,
"name" )
671 << getString( entityData,
"description" )
672 << getVariantMap( entityData,
"unitOfMeasurement" )
673 << getString( entityData,
"observationType" )
675 << phenomenonTime.first
676 << phenomenonTime.second
678 << resultTime.second;
683 attributes << iotId << selfLink << getString( entityData,
"name" ) << getString( entityData,
"description" ) << getString( entityData,
"metadata" ) << properties;
687 attributes << iotId << selfLink << getString( entityData,
"name" ) << getString( entityData,
"definition" ) << getString( entityData,
"description" ) << properties;
692 std::pair< QVariant, QVariant > phenomenonTime = getDateTimeRange( entityData,
"phenomenonTime" );
693 std::pair< QVariant, QVariant > validTime = getDateTimeRange( entityData,
"validTime" );
697 << phenomenonTime.first
698 << phenomenonTime.second
699 << getString( entityData,
"result" )
700 << getDateTime( entityData,
"resultTime" )
701 << getStringList( entityData,
"resultQuality" )
704 << getVariantMap( entityData,
"parameters" );
709 attributes << iotId << selfLink << getString( entityData,
"name" ) << getString( entityData,
"description" ) << properties;
714 std::pair< QVariant, QVariant > phenomenonTime = getDateTimeRange( entityData,
"phenomenonTime" );
715 std::pair< QVariant, QVariant > resultTime = getDateTimeRange( entityData,
"resultTime" );
719 << getString( entityData,
"name" )
720 << getString( entityData,
"description" )
721 << getVariantList( entityData,
"unitOfMeasurements" )
722 << getString( entityData,
"observationType" )
723 << getStringList( entityData,
"multiObservationDataTypes" )
725 << phenomenonTime.first
726 << phenomenonTime.second
728 << resultTime.second;
736 attributes.reserve( fields.
size() );
737 extendAttributes( mEntityType, featureData, attributes );
739 auto processFeature = [
this, &fetchedFeatureCallback](
QgsFeature &feature,
const QString &rawFeatureId ) {
740 feature.
setId( mNextFeatureId++ );
742 mCachedFeatures.insert( feature.
id(), feature );
743 mIotIdToFeatureId.insert( rawFeatureId, feature.
id() );
744 mSpatialIndex.addFeature( feature );
747 fetchedFeatureCallback( feature );
750 const QString baseFeatureId = getString( featureData,
"@iot.id" ).toString();
751 if ( !expansions.empty() )
753 mRetrievedBaseFeatureCount++;
755 std::function< void(
const nlohmann::json &,
Qgis::SensorThingsEntity,
const QList<QgsSensorThingsExpansionDefinition > &,
const QString &,
const QgsAttributes & ) > traverseExpansion;
761 &fetchedFeatureCallback,
763 &processFeature](
const nlohmann::json ¤tLevelData,
Qgis::SensorThingsEntity parentEntityType,
const QList<QgsSensorThingsExpansionDefinition > &expansionTargets,
const QString &lowerLevelId,
const QgsAttributes &lowerLevelAttributes ) {
765 const QList< QgsSensorThingsExpansionDefinition > remainingExpansionTargets = expansionTargets.mid( 1 );
769 QString currentExpansionPropertyString;
770 switch ( cardinality )
783 if ( currentLevelData.contains( currentExpansionPropertyString.toLocal8Bit().constData() ) )
785 auto parseExpandedEntity = [lowerLevelAttributes,
790 &remainingExpansionTargets,
791 &fetchedFeatureCallback,
794 ¤tExpansionTarget,
795 this](
const json &expandedEntityElement ) {
797 const QString expandedEntityIotId = getString( expandedEntityElement,
"@iot.id" ).toString();
798 const QString expandedFeatureId = lowerLevelId +
'_' + expandedEntityIotId;
800 if ( remainingExpansionTargets.empty() )
802 auto existingFeatureIdIt = mIotIdToFeatureId.constFind( expandedFeatureId );
803 if ( existingFeatureIdIt != mIotIdToFeatureId.constEnd() )
806 fetchedFeatureCallback( *mCachedFeatures.find( *existingFeatureIdIt ) );
811 extendAttributes( currentExpansionTarget.childEntity(), expandedEntityElement, expandedAttributes );
812 if ( !remainingExpansionTargets.empty() )
815 traverseExpansion( expandedEntityElement, currentExpansionTarget.childEntity(), remainingExpansionTargets, expandedFeatureId, expandedAttributes );
819 feature.setAttributes( expandedAttributes );
820 processFeature( feature, expandedFeatureId );
823 const auto &expandedEntity = currentLevelData[currentExpansionPropertyString.toLocal8Bit().constData()];
824 if ( expandedEntity.is_array() )
826 for (
const auto &expandedEntityElement : expandedEntity )
828 parseExpandedEntity( expandedEntityElement );
834 else if ( expandedEntity.is_object() )
836 parseExpandedEntity( expandedEntity );
847 traverseExpansion( featureData, mEntityType, expansions, baseFeatureId, attributes );
849 if ( mFeatureLimit > 0 && mFeatureLimit <= mRetrievedBaseFeatureCount )
854 feature.setAttributes( attributes );
855 processFeature( feature, baseFeatureId );
856 mRetrievedBaseFeatureCount++;
857 if ( mFeatureLimit > 0 && mFeatureLimit <= mRetrievedBaseFeatureCount )
864 if ( rootContent.contains(
"@iot.nextLink" ) && ( mFeatureLimit == 0 || mFeatureLimit > mCachedFeatures.size() ) )
866 nextPage = QString::fromStdString( rootContent[
"@iot.nextLink"].get<std::string>() );
870 onNoMoreFeaturesCallback();
874 if ( !continueFetchingCallback() )
880 catch (
const json::parse_error &ex )
883 mError = QObject::tr(
"Error parsing response: %1" ).arg( ex.what() );
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...
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...
Represents a coordinate reference system (CRS).
Stores the component parts of a data source URI (e.g.
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.
A convenience class that simplifies locking and unlocking QReadWriteLocks.
A rectangle specified with double values.
Q_INVOKABLE QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be rounded to the spec...
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)