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
175 : ( !mFilterExtent.isNull() ? mFilterExtent :
QgsRectangle( -180, -90, 180, 90 ) );
178long long QgsSensorThingsSharedData::featureCount(
QgsFeedback *feedback )
const
181 if ( mFeatureCount >= 0 )
182 return mFeatureCount;
190 if ( !mExpansions.isEmpty() )
196 QString countUri = u
"%1?$top=0&$count=true"_s.arg( mEntityBaseUri );
200 if ( !filterString.isEmpty() )
201 filterString = u
"&$filter="_s + filterString;
202 if ( !filterString.isEmpty() )
203 countUri += filterString;
205 const QUrl url = parseUrl( QUrl( countUri ) );
207 QNetworkRequest request( url );
209 mHeaders.updateNetworkRequest( request );
216 return mFeatureCount;
229 auto rootContent = json::parse( content.
content().toStdString() );
230 if ( !rootContent.contains(
"@iot.count" ) )
232 mError = QObject::tr(
"No '@iot.count' value in response" );
233 return mFeatureCount;
236 mFeatureCount = rootContent[
"@iot.count"].get<
long long>();
237 if ( mFeatureLimit > 0 && mFeatureCount > mFeatureLimit )
238 mFeatureCount = mFeatureLimit;
240 catch (
const json::parse_error &ex )
242 mError = QObject::tr(
"Error parsing response: %1" ).arg( ex.what() );
246 return mFeatureCount;
249QString QgsSensorThingsSharedData::subsetString()
const
251 return mSubsetString;
254bool QgsSensorThingsSharedData::hasCachedAllFeatures()
const
257 return mHasCachedAllFeatures
258 || ( mFeatureCount > 0 && mCachedFeatures.size() == mFeatureCount )
259 || ( mFeatureLimit > 0 && mRetrievedBaseFeatureCount >= mFeatureLimit );
267 QMap<QgsFeatureId, QgsFeature>::const_iterator it = mCachedFeatures.constFind(
id );
268 if ( it != mCachedFeatures.constEnd() )
274 if ( hasCachedAllFeatures() )
277 bool featureFetched =
false;
279 if ( mNextPage.isEmpty() )
283 int thisPageSize = mMaximumPageSize;
284 if ( mFeatureLimit > 0 && ( mCachedFeatures.size() + thisPageSize ) > mFeatureLimit )
285 thisPageSize = mFeatureLimit - mCachedFeatures.size();
287 mNextPage = u
"%1?$top=%2&$count=false%3"_s.arg( mEntityBaseUri ).arg( thisPageSize ).arg( !mExpandQueryString.isEmpty() ? ( u
"&"_s + mExpandQueryString ) : QString() );
291 if ( !filterString.isEmpty() )
292 mNextPage += u
"&$filter="_s + filterString;
297 processFeatureRequest( mNextPage, feedback, [
id, &f, &featureFetched](
const QgsFeature & feature )
299 if ( feature.
id() ==
id )
302 featureFetched =
true;
305 }, [&featureFetched,
this]
307 return !featureFetched && !hasCachedAllFeatures();
311 mHasCachedAllFeatures =
true;
314 return featureFetched;
323 if ( hasCachedAllFeatures() || mCachedExtent.contains( extentGeom ) )
327 return qgis::listToSet( mSpatialIndex.intersects( requestExtent ) );
333 if ( !filterString.isEmpty() )
334 filterString = u
"&$filter="_s + filterString;
335 int thisPageSize = mMaximumPageSize;
337 if ( !thisPage.isEmpty() )
340 const thread_local QRegularExpression topRe( u
"\\$top=\\d+"_s );
341 const QRegularExpressionMatch match = topRe.match( queryUrl );
342 if ( match.hasMatch() )
344 if ( mFeatureLimit > 0 && ( mCachedFeatures.size() + thisPageSize ) > mFeatureLimit )
345 thisPageSize = mFeatureLimit - mCachedFeatures.size();
346 queryUrl = queryUrl.left( match.capturedStart( 0 ) ) + u
"$top=%1"_s.arg( thisPageSize ) + queryUrl.mid( match.capturedEnd( 0 ) );
351 queryUrl = u
"%1?$top=%2&$count=false%3%4"_s.arg( mEntityBaseUri ).arg( thisPageSize ).arg( filterString, !mExpandQueryString.isEmpty() ? ( u
"&"_s + mExpandQueryString ) : QString() );
354 if ( thisPage.isEmpty() && mCachedExtent.intersects( extentGeom ) )
360 return qgis::listToSet( mSpatialIndex.intersects( requestExtent ) );
367 bool noMoreFeatures =
false;
368 bool hasFirstPage =
false;
369 const bool res = processFeatureRequest( queryUrl, feedback, [&ids, &alreadyFetchedIds](
const QgsFeature & feature )
371 if ( !alreadyFetchedIds.contains( feature.
id() ) )
372 ids.insert( feature.
id() );
384 noMoreFeatures =
true;
386 if ( noMoreFeatures && res && ( !feedback || !feedback->
isCanceled() ) )
391 nextPage = noMoreFeatures || !res ? QString() : queryUrl;
396void QgsSensorThingsSharedData::clearCache()
401 mCachedFeatures.clear();
402 mIotIdToFeatureId.clear();
407bool QgsSensorThingsSharedData::processFeatureRequest( QString &nextPage,
QgsFeedback *feedback,
const std::function<
void(
const QgsFeature & ) > &fetchedFeatureCallback,
const std::function<
bool ()> &continueFetchingCallback,
const std::function<
void ()> &onNoMoreFeaturesCallback )
412 const QString authcfg = mAuthCfg;
415 const QList< QgsSensorThingsExpansionDefinition > expansions = mExpansions;
417 while ( continueFetchingCallback() )
426 const QUrl url = parseUrl( nextPage );
428 QNetworkRequest request( url );
453 const auto rootContent = json::parse( content.
content().toStdString() );
454 if ( !rootContent.contains(
"value" ) )
457 mError = QObject::tr(
"No 'value' in response" );
464 const auto &values = rootContent[
"value"];
465 if ( values.empty() )
469 onNoMoreFeaturesCallback();
476 for (
const auto &featureData : values )
478 auto getString = [](
const basic_json<> &json,
const char *tag ) -> QVariant
480 if ( !json.contains( tag ) )
483 std::function< QString(
const basic_json<> &obj,
bool &ok ) > objToString;
484 objToString = [&objToString](
const basic_json<> &obj,
bool & ok ) -> QString
487 if ( obj.is_number_integer() )
489 return QString::number( obj.get<
int>() );
491 else if ( obj.is_number_unsigned() )
493 return QString::number( obj.get<
unsigned>() );
495 else if ( obj.is_boolean() )
497 return QString::number( obj.get<
bool>() );
499 else if ( obj.is_number_float() )
501 return QString::number( obj.get<
double>() );
503 else if ( obj.is_array() )
506 results.reserve( obj.size() );
507 for (
const auto &item : obj )
510 const QString itemString = objToString( item, itemOk );
512 results.push_back( itemString );
514 return results.join(
',' );
516 else if ( obj.is_string() )
518 return QString::fromStdString( obj.get<std::string >() );
525 const auto &jObj = json[tag];
527 const QString r = objToString( jObj, ok );
533 auto getDateTime = [](
const basic_json<> &json,
const char *tag ) -> QVariant
535 if ( !json.contains( tag ) )
538 const auto &jObj = json[tag];
539 if ( jObj.is_string() )
541 const QString dateTimeString = QString::fromStdString( json[tag].get<std::string >() );
542 return QDateTime::fromString( dateTimeString, Qt::ISODateWithMs );
548 auto getVariantMap = [](
const basic_json<> &json,
const char *tag ) -> QVariant
550 if ( !json.contains( tag ) )
556 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
566 if ( !json.contains( tag ) )
569 const auto &jObj = json[tag];
570 if ( jObj.is_string() )
572 return QStringList{ QString::fromStdString( json[tag].get<std::string >() ) };
574 else if ( jObj.is_array() )
577 for (
const auto &element : jObj )
579 if ( element.is_string() )
580 res.append( QString::fromStdString( element.get<std::string >() ) );
588 auto getDateTimeRange = [](
const basic_json<> &json,
const char *tag ) -> std::pair< QVariant, QVariant >
590 if ( !json.contains( tag ) )
591 return { QVariant(), QVariant() };
593 const auto &jObj = json[tag];
594 if ( jObj.is_string() )
596 const QString rangeString = QString::fromStdString( json[tag].get<std::string >() );
597 const QStringList rangeParts = rangeString.split(
'/' );
598 if ( rangeParts.size() == 2 )
602 QDateTime::fromString( rangeParts.at( 0 ), Qt::ISODateWithMs ),
603 QDateTime::fromString( rangeParts.at( 1 ), Qt::ISODateWithMs )
608 const QDateTime instant = QDateTime::fromString( rangeString, Qt::ISODateWithMs );
609 if ( instant.isValid() )
610 return { instant, instant };
614 return { QVariant(), QVariant() };
617 const QString iotId = getString( featureData,
"@iot.id" ).toString();
618 if ( expansions.isEmpty() )
620 auto existingFeatureIdIt = mIotIdToFeatureId.constFind( iotId );
621 if ( existingFeatureIdIt != mIotIdToFeatureId.constEnd() )
624 fetchedFeatureCallback( *mCachedFeatures.find( *existingFeatureIdIt ) );
634 if ( featureData.contains( mGeometryField.toLocal8Bit().constData() ) )
636 const auto &geometryPart = featureData[mGeometryField.toLocal8Bit().constData()];
637 if ( geometryPart.contains(
"geometry" ) )
644 auto extendAttributes = [&getString, &getVariantMap, &getDateTimeRange, &getDateTime, &getStringList, &getVariantList](
Qgis::SensorThingsEntity entityType,
const auto & entityData,
QgsAttributes & attributes )
646 const QString iotId = getString( entityData,
"@iot.id" ).toString();
647 const QString selfLink = getString( entityData,
"@iot.selfLink" ).toString();
649 const QVariant properties = getVariantMap( entityData,
"properties" );
652 switch ( entityType )
661 << getString( entityData,
"name" )
662 << getString( entityData,
"description" )
670 << getString( entityData,
"name" )
671 << getString( entityData,
"description" )
679 << getDateTime( entityData,
"time" );
684 std::pair< QVariant, QVariant > phenomenonTime = getDateTimeRange( entityData,
"phenomenonTime" );
685 std::pair< QVariant, QVariant > resultTime = getDateTimeRange( entityData,
"resultTime" );
689 << getString( entityData,
"name" )
690 << getString( entityData,
"description" )
691 << getVariantMap( entityData,
"unitOfMeasurement" )
692 << getString( entityData,
"observationType" )
694 << phenomenonTime.first
695 << phenomenonTime.second
697 << resultTime.second;
705 << getString( entityData,
"name" )
706 << getString( entityData,
"description" )
707 << getString( entityData,
"metadata" )
715 << getString( entityData,
"name" )
716 << getString( entityData,
"definition" )
717 << getString( entityData,
"description" )
723 std::pair< QVariant, QVariant > phenomenonTime = getDateTimeRange( entityData,
"phenomenonTime" );
724 std::pair< QVariant, QVariant > validTime = getDateTimeRange( entityData,
"validTime" );
728 << phenomenonTime.first
729 << phenomenonTime.second
730 << getString( entityData,
"result" )
731 << getDateTime( entityData,
"resultTime" )
732 << getStringList( entityData,
"resultQuality" )
735 << getVariantMap( entityData,
"parameters" );
743 << getString( entityData,
"name" )
744 << getString( entityData,
"description" )
750 std::pair< QVariant, QVariant > phenomenonTime = getDateTimeRange( entityData,
"phenomenonTime" );
751 std::pair< QVariant, QVariant > resultTime = getDateTimeRange( entityData,
"resultTime" );
755 << getString( entityData,
"name" )
756 << getString( entityData,
"description" )
757 << getVariantList( entityData,
"unitOfMeasurements" )
758 << getString( entityData,
"observationType" )
759 << getStringList( entityData,
"multiObservationDataTypes" )
761 << phenomenonTime.first
762 << phenomenonTime.second
764 << resultTime.second;
772 attributes.reserve( fields.
size() );
773 extendAttributes( mEntityType, featureData, attributes );
775 auto processFeature = [
this, &fetchedFeatureCallback](
QgsFeature & feature,
const QString & rawFeatureId )
777 feature.
setId( mNextFeatureId++ );
779 mCachedFeatures.insert( feature.
id(), feature );
780 mIotIdToFeatureId.insert( rawFeatureId, feature.
id() );
781 mSpatialIndex.addFeature( feature );
784 fetchedFeatureCallback( feature );
787 const QString baseFeatureId = getString( featureData,
"@iot.id" ).toString();
788 if ( !expansions.empty() )
790 mRetrievedBaseFeatureCount++;
792 std::function< void(
const nlohmann::json &,
Qgis::SensorThingsEntity,
const QList<QgsSensorThingsExpansionDefinition > &,
const QString &,
const QgsAttributes & ) > traverseExpansion;
793 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 )
796 const QList< QgsSensorThingsExpansionDefinition > remainingExpansionTargets = expansionTargets.mid( 1 );
800 QString currentExpansionPropertyString;
801 switch ( cardinality )
814 if ( currentLevelData.contains( currentExpansionPropertyString.toLocal8Bit().constData() ) )
816 auto parseExpandedEntity = [lowerLevelAttributes, &feature, &processFeature, &lowerLevelId, &getString, &remainingExpansionTargets, &fetchedFeatureCallback, &extendAttributes, &traverseExpansion, ¤tExpansionTarget,
this](
const json & expandedEntityElement )
819 const QString expandedEntityIotId = getString( expandedEntityElement,
"@iot.id" ).toString();
820 const QString expandedFeatureId = lowerLevelId +
'_' + expandedEntityIotId;
822 if ( remainingExpansionTargets.empty() )
824 auto existingFeatureIdIt = mIotIdToFeatureId.constFind( expandedFeatureId );
825 if ( existingFeatureIdIt != mIotIdToFeatureId.constEnd() )
828 fetchedFeatureCallback( *mCachedFeatures.find( *existingFeatureIdIt ) );
833 extendAttributes( currentExpansionTarget.childEntity(), expandedEntityElement, expandedAttributes );
834 if ( !remainingExpansionTargets.empty() )
837 traverseExpansion( expandedEntityElement, currentExpansionTarget.childEntity(), remainingExpansionTargets, expandedFeatureId, expandedAttributes );
841 feature.setAttributes( expandedAttributes );
842 processFeature( feature, expandedFeatureId );
845 const auto &expandedEntity = currentLevelData[currentExpansionPropertyString.toLocal8Bit().constData()];
846 if ( expandedEntity.is_array() )
848 for (
const auto &expandedEntityElement : expandedEntity )
850 parseExpandedEntity( expandedEntityElement );
856 else if ( expandedEntity.is_object() )
858 parseExpandedEntity( expandedEntity );
869 traverseExpansion( featureData, mEntityType, expansions, baseFeatureId, attributes );
871 if ( mFeatureLimit > 0 && mFeatureLimit <= mRetrievedBaseFeatureCount )
876 feature.setAttributes( attributes );
877 processFeature( feature, baseFeatureId );
878 mRetrievedBaseFeatureCount++;
879 if ( mFeatureLimit > 0 && mFeatureLimit <= mRetrievedBaseFeatureCount )
886 if ( rootContent.contains(
"@iot.nextLink" ) && ( mFeatureLimit == 0 || mFeatureLimit > mCachedFeatures.size() ) )
888 nextPage = QString::fromStdString( rootContent[
"@iot.nextLink"].get<std::string>() );
892 onNoMoreFeaturesCallback();
896 if ( !continueFetchingCallback() )
902 catch (
const json::parse_error &ex )
905 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 truncated to the sp...
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)