18#include <nlohmann/json.hpp>
29#include <QNetworkRequest>
30#include <QRegularExpression>
31#include <QRegularExpressionMatch>
68 QStringLiteral(
"phenomenonTime" ), Qt::SortOrder::DescendingOrder
77 QString(), Qt::SortOrder::AscendingOrder, 10
95 mChildEntity = entity;
135 if ( !mOrderBy.isEmpty() )
136 parts.append( QStringLiteral(
"orderby=%1,%2" ).arg( mOrderBy, mSortOrder == Qt::SortOrder::AscendingOrder ? QStringLiteral(
"asc" ) : QStringLiteral(
"desc" ) ) );
138 parts.append( QStringLiteral(
"limit=%1" ).arg( mLimit ) );
139 if ( !mFilter.trimmed().isEmpty() )
141 QString escapedFilter = mFilter;
142 escapedFilter.replace(
':', QLatin1String(
"\\colon" ) );
143 parts.append( QStringLiteral(
"filter=%1" ).arg( escapedFilter ) );
145 return parts.join(
':' );
150 const QStringList parts =
string.split(
':', Qt::SkipEmptyParts );
156 for (
int i = 1; i < parts.count(); ++i )
158 const QString &part = parts.at( i );
159 const thread_local QRegularExpression orderByRegEx( QStringLiteral(
"^orderby=(.*),(.*?)$" ) );
160 const thread_local QRegularExpression orderLimitRegEx( QStringLiteral(
"^limit=(\\d+)$" ) );
161 const thread_local QRegularExpression filterRegEx( QStringLiteral(
"^filter=(.*)$" ) );
163 const QRegularExpressionMatch orderByMatch = orderByRegEx.match( part );
164 if ( orderByMatch.hasMatch() )
166 definition.
setOrderBy( orderByMatch.captured( 1 ) );
167 definition.
setSortOrder( orderByMatch.captured( 2 ) == QLatin1String(
"asc" ) ? Qt::SortOrder::AscendingOrder : Qt::SortOrder::DescendingOrder );
171 const QRegularExpressionMatch limitMatch = orderLimitRegEx.match( part );
172 if ( limitMatch.hasMatch() )
174 definition.
setLimit( limitMatch.captured( 1 ).toInt() );
178 const QRegularExpressionMatch filterMatch = filterRegEx.match( part );
179 if ( filterMatch.hasMatch() )
181 QString
filter = filterMatch.captured( 1 );
182 filter.replace( QLatin1String(
"\\colon" ), QLatin1String(
":" ) );
199 QString childEntityString;
206 switch ( cardinality )
222 QString res = QStringLiteral(
"$expand=%1" ).arg( childEntityString );
224 QStringList queryOptions;
225 if ( !mOrderBy.isEmpty() )
226 queryOptions.append( QStringLiteral(
"$orderby=%1%2" ).arg( mOrderBy, mSortOrder == Qt::SortOrder::AscendingOrder ? QString() : QStringLiteral(
" desc" ) ) );
229 queryOptions.append( QStringLiteral(
"$top=%1" ).arg( mLimit ) );
231 if ( !mFilter.isEmpty() )
232 queryOptions.append( QStringLiteral(
"$filter=%1" ).arg( mFilter ) );
234 queryOptions.append( additionalOptions );
236 if ( !queryOptions.isEmpty() )
237 res.append( QStringLiteral(
"(%1)" ).arg( queryOptions.join(
';' ) ) );
247 return mChildEntity == other.mChildEntity
248 && mSortOrder == other.mSortOrder
249 && mLimit == other.mLimit
250 && mOrderBy == other.mOrderBy
251 && mFilter == other.mFilter;
256 return !( *
this == other );
275 const QString trimmed = type.trimmed();
276 if ( trimmed.compare( QLatin1String(
"Thing" ), Qt::CaseInsensitive ) == 0 )
278 if ( trimmed.compare( QLatin1String(
"Location" ), Qt::CaseInsensitive ) == 0 )
280 if ( trimmed.compare( QLatin1String(
"HistoricalLocation" ), Qt::CaseInsensitive ) == 0 )
282 if ( trimmed.compare( QLatin1String(
"Datastream" ), Qt::CaseInsensitive ) == 0 )
284 if ( trimmed.compare( QLatin1String(
"Sensor" ), Qt::CaseInsensitive ) == 0 )
286 if ( trimmed.compare( QLatin1String(
"ObservedProperty" ), Qt::CaseInsensitive ) == 0 )
288 if ( trimmed.compare( QLatin1String(
"Observation" ), Qt::CaseInsensitive ) == 0 )
290 if ( trimmed.compare( QLatin1String(
"FeatureOfInterest" ), Qt::CaseInsensitive ) == 0 )
292 if ( trimmed.compare( QLatin1String(
"MultiDatastream" ), Qt::CaseInsensitive ) == 0 )
305 return plural ? QObject::tr(
"Things" ) : QObject::tr(
"Thing" );
307 return plural ? QObject::tr(
"Locations" ) : QObject::tr(
"Location" );
309 return plural ? QObject::tr(
"Historical Locations" ) : QObject::tr(
"Historical Location" );
311 return plural ? QObject::tr(
"Datastreams" ) : QObject::tr(
"Datastream" );
313 return plural ? QObject::tr(
"Sensors" ) : QObject::tr(
"Sensor" );
315 return plural ? QObject::tr(
"Observed Properties" ) : QObject::tr(
"Observed Property" );
317 return plural ? QObject::tr(
"Observations" ) : QObject::tr(
"Observation" );
319 return plural ? QObject::tr(
"Features of Interest" ) : QObject::tr(
"Feature of Interest" );
321 return plural ? QObject::tr(
"MultiDatastreams" ) : QObject::tr(
"MultiDatastream" );
328 const QString trimmed = type.trimmed();
329 if ( trimmed.compare( QLatin1String(
"Things" ), Qt::CaseInsensitive ) == 0 )
331 if ( trimmed.compare( QLatin1String(
"Locations" ), Qt::CaseInsensitive ) == 0 )
333 if ( trimmed.compare( QLatin1String(
"HistoricalLocations" ), Qt::CaseInsensitive ) == 0 )
335 if ( trimmed.compare( QLatin1String(
"Datastreams" ), Qt::CaseInsensitive ) == 0 )
337 if ( trimmed.compare( QLatin1String(
"Sensors" ), Qt::CaseInsensitive ) == 0 )
339 if ( trimmed.compare( QLatin1String(
"ObservedProperties" ), Qt::CaseInsensitive ) == 0 )
341 if ( trimmed.compare( QLatin1String(
"Observations" ), Qt::CaseInsensitive ) == 0 )
343 if ( trimmed.compare( QLatin1String(
"FeaturesOfInterest" ), Qt::CaseInsensitive ) == 0 )
345 if ( trimmed.compare( QLatin1String(
"MultiDatastreams" ), Qt::CaseInsensitive ) == 0 )
358 return QStringLiteral(
"Things" );
360 return QStringLiteral(
"Locations" );
362 return QStringLiteral(
"HistoricalLocations" );
364 return QStringLiteral(
"Datastreams" );
366 return QStringLiteral(
"Sensors" );
368 return QStringLiteral(
"ObservedProperties" );
370 return QStringLiteral(
"Observations" );
372 return QStringLiteral(
"FeaturesOfInterest" );
374 return QStringLiteral(
"MultiDatastreams" );
388 return { QStringLiteral(
"id" ),
389 QStringLiteral(
"selfLink" ),
390 QStringLiteral(
"name" ),
391 QStringLiteral(
"description" ),
392 QStringLiteral(
"properties" ),
397 return { QStringLiteral(
"id" ),
398 QStringLiteral(
"selfLink" ),
399 QStringLiteral(
"name" ),
400 QStringLiteral(
"description" ),
401 QStringLiteral(
"properties" ),
406 return { QStringLiteral(
"id" ),
407 QStringLiteral(
"selfLink" ),
408 QStringLiteral(
"time" ),
413 return { QStringLiteral(
"id" ),
414 QStringLiteral(
"selfLink" ),
415 QStringLiteral(
"name" ),
416 QStringLiteral(
"description" ),
417 QStringLiteral(
"unitOfMeasurement" ),
418 QStringLiteral(
"observationType" ),
419 QStringLiteral(
"properties" ),
420 QStringLiteral(
"phenomenonTime" ),
421 QStringLiteral(
"resultTime" ),
426 return { QStringLiteral(
"id" ),
427 QStringLiteral(
"selfLink" ),
428 QStringLiteral(
"name" ),
429 QStringLiteral(
"description" ),
430 QStringLiteral(
"metadata" ),
431 QStringLiteral(
"properties" ),
436 return { QStringLiteral(
"id" ),
437 QStringLiteral(
"selfLink" ),
438 QStringLiteral(
"name" ),
439 QStringLiteral(
"definition" ),
440 QStringLiteral(
"description" ),
441 QStringLiteral(
"properties" ),
446 return { QStringLiteral(
"id" ),
447 QStringLiteral(
"selfLink" ),
448 QStringLiteral(
"phenomenonTime" ),
449 QStringLiteral(
"result" ),
450 QStringLiteral(
"resultTime" ),
451 QStringLiteral(
"resultQuality" ),
452 QStringLiteral(
"validTime" ),
453 QStringLiteral(
"parameters" ),
458 return { QStringLiteral(
"id" ),
459 QStringLiteral(
"selfLink" ),
460 QStringLiteral(
"name" ),
461 QStringLiteral(
"description" ),
462 QStringLiteral(
"properties" ),
467 return { QStringLiteral(
"id" ),
468 QStringLiteral(
"selfLink" ),
469 QStringLiteral(
"name" ),
470 QStringLiteral(
"description" ),
471 QStringLiteral(
"unitOfMeasurements" ),
472 QStringLiteral(
"observationType" ),
473 QStringLiteral(
"multiObservationDataTypes" ),
474 QStringLiteral(
"properties" ),
475 QStringLiteral(
"phenomenonTime" ),
476 QStringLiteral(
"resultTime" ),
488 fields.
append(
QgsField( QStringLiteral(
"id" ), QMetaType::Type::QString ) );
489 fields.
append(
QgsField( QStringLiteral(
"selfLink" ), QMetaType::Type::QString ) );
498 fields.
append(
QgsField( QStringLiteral(
"name" ), QMetaType::Type::QString ) );
499 fields.
append(
QgsField( QStringLiteral(
"description" ), QMetaType::Type::QString ) );
500 fields.
append(
QgsField( QStringLiteral(
"properties" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
505 fields.
append(
QgsField( QStringLiteral(
"name" ), QMetaType::Type::QString ) );
506 fields.
append(
QgsField( QStringLiteral(
"description" ), QMetaType::Type::QString ) );
507 fields.
append(
QgsField( QStringLiteral(
"properties" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
512 fields.
append(
QgsField( QStringLiteral(
"time" ), QMetaType::Type::QDateTime ) );
517 fields.
append(
QgsField( QStringLiteral(
"name" ), QMetaType::Type::QString ) );
518 fields.
append(
QgsField( QStringLiteral(
"description" ), QMetaType::Type::QString ) );
519 fields.
append(
QgsField( QStringLiteral(
"unitOfMeasurement" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
520 fields.
append(
QgsField( QStringLiteral(
"observationType" ), QMetaType::Type::QString ) );
521 fields.
append(
QgsField( QStringLiteral(
"properties" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
522 if ( includeRangeFieldProxies )
524 fields.
append(
QgsField( QStringLiteral(
"phenomenonTimeStart" ), QMetaType::Type::QDateTime ) );
525 fields.
append(
QgsField( QStringLiteral(
"phenomenonTimeEnd" ), QMetaType::Type::QDateTime ) );
526 fields.
append(
QgsField( QStringLiteral(
"resultTimeStart" ), QMetaType::Type::QDateTime ) );
527 fields.
append(
QgsField( QStringLiteral(
"resultTimeEnd" ), QMetaType::Type::QDateTime ) );
533 fields.
append(
QgsField( QStringLiteral(
"name" ), QMetaType::Type::QString ) );
534 fields.
append(
QgsField( QStringLiteral(
"description" ), QMetaType::Type::QString ) );
535 fields.
append(
QgsField( QStringLiteral(
"metadata" ), QMetaType::Type::QString ) );
536 fields.
append(
QgsField( QStringLiteral(
"properties" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
541 fields.
append(
QgsField( QStringLiteral(
"name" ), QMetaType::Type::QString ) );
542 fields.
append(
QgsField( QStringLiteral(
"definition" ), QMetaType::Type::QString ) );
543 fields.
append(
QgsField( QStringLiteral(
"description" ), QMetaType::Type::QString ) );
544 fields.
append(
QgsField( QStringLiteral(
"properties" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
549 if ( includeRangeFieldProxies )
551 fields.
append(
QgsField( QStringLiteral(
"phenomenonTimeStart" ), QMetaType::Type::QDateTime ) );
552 fields.
append(
QgsField( QStringLiteral(
"phenomenonTimeEnd" ), QMetaType::Type::QDateTime ) );
556 fields.
append(
QgsField( QStringLiteral(
"result" ), QMetaType::Type::QString ) );
558 fields.
append(
QgsField( QStringLiteral(
"resultTime" ), QMetaType::Type::QDateTime ) );
559 fields.
append(
QgsField( QStringLiteral(
"resultQuality" ), QMetaType::Type::QStringList, QString(), 0, 0, QString(), QMetaType::Type::QString ) );
560 if ( includeRangeFieldProxies )
562 fields.
append(
QgsField( QStringLiteral(
"validTimeStart" ), QMetaType::Type::QDateTime ) );
563 fields.
append(
QgsField( QStringLiteral(
"validTimeEnd" ), QMetaType::Type::QDateTime ) );
565 fields.
append(
QgsField( QStringLiteral(
"parameters" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
570 fields.
append(
QgsField( QStringLiteral(
"name" ), QMetaType::Type::QString ) );
571 fields.
append(
QgsField( QStringLiteral(
"description" ), QMetaType::Type::QString ) );
572 fields.
append(
QgsField( QStringLiteral(
"properties" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
577 fields.
append(
QgsField( QStringLiteral(
"name" ), QMetaType::Type::QString ) );
578 fields.
append(
QgsField( QStringLiteral(
"description" ), QMetaType::Type::QString ) );
579 fields.
append(
QgsField( QStringLiteral(
"unitOfMeasurements" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
580 fields.
append(
QgsField( QStringLiteral(
"observationType" ), QMetaType::Type::QString ) );
581 fields.
append(
QgsField( QStringLiteral(
"multiObservationDataTypes" ), QMetaType::Type::QStringList, QString(), 0, 0, QString(), QMetaType::Type::QString ) );
582 fields.
append(
QgsField( QStringLiteral(
"properties" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
583 if ( includeRangeFieldProxies )
585 fields.
append(
QgsField( QStringLiteral(
"phenomenonTimeStart" ), QMetaType::Type::QDateTime ) );
586 fields.
append(
QgsField( QStringLiteral(
"phenomenonTimeEnd" ), QMetaType::Type::QDateTime ) );
587 fields.
append(
QgsField( QStringLiteral(
"resultTimeStart" ), QMetaType::Type::QDateTime ) );
588 fields.
append(
QgsField( QStringLiteral(
"resultTimeEnd" ), QMetaType::Type::QDateTime ) );
598 if ( expandedTypes.empty() )
605 path = ( path.isEmpty() ? QString() : ( path +
'_' ) ) +
qgsEnumValueToKey( expandedType );
607 for (
const QgsField &expandedField : expandedFields )
609 QgsField renamedExpandedField = expandedField;
610 renamedExpandedField.
setName( QStringLiteral(
"%1_%2" ).arg( path, expandedField.name() ) );
611 fields.
append( renamedExpandedField );
630 return QStringLiteral(
"location" );
633 return QStringLiteral(
"feature" );
637 return QStringLiteral(
"observedArea" );
686 QString geometryTypeString;
690 geometryTypeString = QStringLiteral(
"Point" );
693 geometryTypeString = QStringLiteral(
"Polygon" );
696 geometryTypeString = QStringLiteral(
"LineString" );
705 if ( filterTarget.isEmpty() )
708 return QStringLiteral(
"%1/type eq '%2' or %1/geometry/type eq '%2'" ).arg( filterTarget, geometryTypeString );
714 return ( extent.
isNull() || geometryField.isEmpty() )
716 : QStringLiteral(
"geo.intersects(%1, geography'%2')" ).arg( geometryField, extent.
asWktPolygon() );
721 QStringList nonEmptyFilters;
722 for (
const QString &filter : filters )
724 if ( !filter.isEmpty() )
725 nonEmptyFilters.append( filter );
727 if ( nonEmptyFilters.empty() )
729 if ( nonEmptyFilters.size() == 1 )
730 return nonEmptyFilters.at( 0 );
732 return QStringLiteral(
"(" ) + nonEmptyFilters.join( QLatin1String(
") and (" ) ) + QStringLiteral(
")" );
737 QNetworkRequest request = QNetworkRequest( QUrl( uri ) );
743 switch ( networkRequest.
get( request ) )
755 QString entityBaseUri;
759 auto rootContent = nlohmann::json::parse( content.
content().toStdString() );
760 if ( !rootContent.contains(
"value" ) )
762 QgsDebugError( QStringLiteral(
"No 'value' array in response" ) );
766 bool foundMatchingEntity =
false;
767 for (
const auto &valueJson : rootContent[
"value"] )
769 if ( valueJson.contains(
"name" ) && valueJson.contains(
"url" ) )
771 const QString name = QString::fromStdString( valueJson[
"name"].get<std::string>() );
773 if ( entityType == type )
775 const QString url = QString::fromStdString( valueJson[
"url"].get<std::string>() );
776 if ( !url.isEmpty() )
778 foundMatchingEntity =
true;
786 if ( !foundMatchingEntity )
792 catch (
const nlohmann::json::parse_error &ex )
794 QgsDebugError( QStringLiteral(
"Error parsing response: %1" ).arg( ex.what() ) );
798 auto getCountForType = [entityBaseUri, type, authCfg, feedback](
Qgis::GeometryType geometryType ) ->
long long
801 QString countUri = QStringLiteral(
"%1?$top=0&$count=true" ).arg( entityBaseUri );
804 if ( !typeFilter.isEmpty() )
805 countUri += QStringLiteral(
"&$filter=" ) + typeFilter;
807 const QUrl url( countUri );
809 QNetworkRequest request( url );
830 auto rootContent = nlohmann::json::parse( content.
content().toStdString() );
831 if ( !rootContent.contains(
"@iot.count" ) )
833 QgsDebugError( QStringLiteral(
"No '@iot.count' value in response" ) );
837 return rootContent[
"@iot.count"].get<
long long>();
839 catch (
const nlohmann::json::parse_error &ex )
841 QgsDebugError( QStringLiteral(
"Error parsing response: %1" ).arg( ex.what() ) );
847 QList<Qgis::GeometryType> types;
855 const long long matchCount = getCountForType( geometryType );
856 if ( matchCount < 0 )
858 else if ( matchCount > 0 )
859 types.append( geometryType );
955 switch ( relatedType )
977 switch ( relatedType )
997 switch ( relatedType )
1026 switch ( relatedType )
1050 switch ( relatedType )
1072 switch ( relatedType )
1095 switch ( relatedType )
1116 switch ( relatedType )
1138 switch ( relatedType )
1169 for (
int i = expansions.size() - 1; i >= 0 ; i-- )
1177 res = expansion.
asQueryString( parentType, res.isEmpty() ? QStringList() : QStringList{ res } );
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...
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
RelationshipCardinality
Relationship cardinality.
@ ManyToMany
Many to many relationship.
@ ManyToOne
Many to one relationship.
@ OneToOne
One to one relationship.
@ OneToMany
One to many relationship.
WkbType
The WKB type describes the number of dimensions a geometry has.
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.
@ 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...
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.
Encapsulate a field in an attribute table or data source.
void setName(const QString &name)
Set the field name.
Container of fields for a vector layer.
bool append(const QgsField &field, Qgis::FieldOrigin origin=Qgis::FieldOrigin::Provider, int originIndex=-1)
Appends a field.
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 rectangle specified with double values.
Q_INVOKABLE QString asWktPolygon() const
Returns a string representation of the rectangle as a WKT Polygon.
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.
void setLimit(int limit)
Sets the limit on the number of child features to fetch.
void setChildEntity(Qgis::SensorThingsEntity entity)
Sets the target child entity which should be expanded.
void setSortOrder(Qt::SortOrder order)
Sets the sort order for the expanded child entities.
static QgsSensorThingsExpansionDefinition defaultDefinitionForEntity(Qgis::SensorThingsEntity entity)
Returns an expansion definition for the specified entity type, populated with reasonable defaults whi...
static QgsSensorThingsExpansionDefinition fromString(const QString &string)
Returns a QgsSensorThingsExpansionDefinition from a string representation.
bool operator!=(const QgsSensorThingsExpansionDefinition &other) const
void setFilter(const QString &filter)
Returns the the string filter to filter expanded child entities by.
QString asQueryString(Qgis::SensorThingsEntity parentEntityType, const QStringList &additionalOptions=QStringList()) const
Returns the expansion as a valid SensorThings API query string, eg "$expand=Observations($orderby=phe...
bool operator==(const QgsSensorThingsExpansionDefinition &other) const
int limit() const
Returns the limit on the number of child features to fetch.
void setOrderBy(const QString &field)
Sets the field name to order the expanded child entities by.
Qt::SortOrder sortOrder() const
Returns the sort order for the expanded child entities.
QString toString() const
Returns a string encapsulation of the expansion definition.
QString orderBy() const
Returns the field name to order the expanded child entities by.
QString filter() const
Returns the the string filter to filter expanded child entities by.
QgsSensorThingsExpansionDefinition(Qgis::SensorThingsEntity childEntity=Qgis::SensorThingsEntity::Invalid, const QString &orderBy=QString(), Qt::SortOrder sortOrder=Qt::SortOrder::AscendingOrder, int limit=QgsSensorThingsUtils::DEFAULT_EXPANSION_LIMIT, const QString &filter=QString())
Constructor for QgsSensorThingsExpansionDefinition, targeting the specified child entity type.
bool isValid() const
Returns true if the definition is valid.
static QStringList propertiesForEntityType(Qgis::SensorThingsEntity type)
Returns the SensorThings properties which correspond to a specified entity type.
static QList< Qgis::GeometryType > availableGeometryTypes(const QString &uri, Qgis::SensorThingsEntity type, QgsFeedback *feedback=nullptr, const QString &authCfg=QString())
Returns a list of available geometry types for the server at the specified uri and entity type.
static Qgis::SensorThingsEntity stringToEntity(const QString &type)
Converts a string value to a Qgis::SensorThingsEntity type.
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 Qgis::SensorThingsEntity entitySetStringToEntity(const QString &type)
Converts a string value corresponding to a SensorThings entity set to a Qgis::SensorThingsEntity type...
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 Qgis::GeometryType geometryTypeForEntity(Qgis::SensorThingsEntity type)
Returns the geometry type for if the specified entity type.
static QgsFields fieldsForEntityType(Qgis::SensorThingsEntity type, bool includeRangeFieldProxies=true)
Returns the fields which correspond to a specified entity type.
static QString displayString(Qgis::SensorThingsEntity type, bool plural=false)
Converts a Qgis::SensorThingsEntity type to a user-friendly translated string.
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 QList< Qgis::SensorThingsEntity > expandableTargets(Qgis::SensorThingsEntity type)
Returns a list of permissible expand targets for a given base entity type.
static QString filterForExtent(const QString &geometryField, const QgsRectangle &extent)
Returns a filter string which restricts results to those within the specified extent.
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...
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.
#define BUILTIN_UNREACHABLE
#define QgsDebugError(str)
#define QgsSetRequestInitiatorClass(request, _class)