26#include <QNetworkRequest>
27#include <QRegularExpression>
28#include <QRegularExpressionMatch>
29#include <nlohmann/json.hpp>
36 : mChildEntity( childEntity )
38 , mSortOrder( sortOrder )
66 QStringLiteral(
"phenomenonTime" ), Qt::SortOrder::DescendingOrder
75 QString(), Qt::SortOrder::AscendingOrder, 10
93 mChildEntity = entity;
133 if ( !mOrderBy.isEmpty() )
134 parts.append( QStringLiteral(
"orderby=%1,%2" ).arg( mOrderBy, mSortOrder == Qt::SortOrder::AscendingOrder ? QStringLiteral(
"asc" ) : QStringLiteral(
"desc" ) ) );
136 parts.append( QStringLiteral(
"limit=%1" ).arg( mLimit ) );
137 if ( !mFilter.trimmed().isEmpty() )
139 QString escapedFilter = mFilter;
140 escapedFilter.replace(
':', QLatin1String(
"\\colon" ) );
141 parts.append( QStringLiteral(
"filter=%1" ).arg( escapedFilter ) );
143 return parts.join(
':' );
148 const QStringList parts =
string.split(
':', Qt::SkipEmptyParts );
154 for (
int i = 1; i < parts.count(); ++i )
156 const QString &part = parts.at( i );
157 const thread_local QRegularExpression orderByRegEx( QStringLiteral(
"^orderby=(.*),(.*?)$" ) );
158 const thread_local QRegularExpression orderLimitRegEx( QStringLiteral(
"^limit=(\\d+)$" ) );
159 const thread_local QRegularExpression filterRegEx( QStringLiteral(
"^filter=(.*)$" ) );
161 const QRegularExpressionMatch orderByMatch = orderByRegEx.match( part );
162 if ( orderByMatch.hasMatch() )
164 definition.
setOrderBy( orderByMatch.captured( 1 ) );
165 definition.
setSortOrder( orderByMatch.captured( 2 ) == QLatin1String(
"asc" ) ? Qt::SortOrder::AscendingOrder : Qt::SortOrder::DescendingOrder );
169 const QRegularExpressionMatch limitMatch = orderLimitRegEx.match( part );
170 if ( limitMatch.hasMatch() )
172 definition.
setLimit( limitMatch.captured( 1 ).toInt() );
176 const QRegularExpressionMatch filterMatch = filterRegEx.match( part );
177 if ( filterMatch.hasMatch() )
179 QString
filter = filterMatch.captured( 1 );
180 filter.replace( QLatin1String(
"\\colon" ), QLatin1String(
":" ) );
197 QString childEntityString;
204 switch ( cardinality )
220 QString res = QStringLiteral(
"$expand=%1" ).arg( childEntityString );
222 QStringList queryOptions;
223 if ( !mOrderBy.isEmpty() )
224 queryOptions.append( QStringLiteral(
"$orderby=%1%2" ).arg( mOrderBy, mSortOrder == Qt::SortOrder::AscendingOrder ? QString() : QStringLiteral(
" desc" ) ) );
227 queryOptions.append( QStringLiteral(
"$top=%1" ).arg( mLimit ) );
229 if ( !mFilter.isEmpty() )
230 queryOptions.append( QStringLiteral(
"$filter=%1" ).arg( mFilter ) );
232 queryOptions.append( additionalOptions );
234 if ( !queryOptions.isEmpty() )
235 res.append( QStringLiteral(
"(%1)" ).arg( queryOptions.join(
';' ) ) );
245 return mChildEntity == other.mChildEntity
246 && mSortOrder == other.mSortOrder
247 && mLimit == other.mLimit
248 && mOrderBy == other.mOrderBy
249 && mFilter == other.mFilter;
254 return !( *
this == other );
273 const QString trimmed = type.trimmed();
274 if ( trimmed.compare( QLatin1String(
"Thing" ), Qt::CaseInsensitive ) == 0 )
276 if ( trimmed.compare( QLatin1String(
"Location" ), Qt::CaseInsensitive ) == 0 )
278 if ( trimmed.compare( QLatin1String(
"HistoricalLocation" ), Qt::CaseInsensitive ) == 0 )
280 if ( trimmed.compare( QLatin1String(
"Datastream" ), Qt::CaseInsensitive ) == 0 )
282 if ( trimmed.compare( QLatin1String(
"Sensor" ), Qt::CaseInsensitive ) == 0 )
284 if ( trimmed.compare( QLatin1String(
"ObservedProperty" ), Qt::CaseInsensitive ) == 0 )
286 if ( trimmed.compare( QLatin1String(
"Observation" ), Qt::CaseInsensitive ) == 0 )
288 if ( trimmed.compare( QLatin1String(
"FeatureOfInterest" ), Qt::CaseInsensitive ) == 0 )
290 if ( trimmed.compare( QLatin1String(
"MultiDatastream" ), Qt::CaseInsensitive ) == 0 )
303 return plural ? QObject::tr(
"Things" ) : QObject::tr(
"Thing" );
305 return plural ? QObject::tr(
"Locations" ) : QObject::tr(
"Location" );
307 return plural ? QObject::tr(
"Historical Locations" ) : QObject::tr(
"Historical Location" );
309 return plural ? QObject::tr(
"Datastreams" ) : QObject::tr(
"Datastream" );
311 return plural ? QObject::tr(
"Sensors" ) : QObject::tr(
"Sensor" );
313 return plural ? QObject::tr(
"Observed Properties" ) : QObject::tr(
"Observed Property" );
315 return plural ? QObject::tr(
"Observations" ) : QObject::tr(
"Observation" );
317 return plural ? QObject::tr(
"Features of Interest" ) : QObject::tr(
"Feature of Interest" );
319 return plural ? QObject::tr(
"MultiDatastreams" ) : QObject::tr(
"MultiDatastream" );
326 const QString trimmed = type.trimmed();
327 if ( trimmed.compare( QLatin1String(
"Things" ), Qt::CaseInsensitive ) == 0 )
329 if ( trimmed.compare( QLatin1String(
"Locations" ), Qt::CaseInsensitive ) == 0 )
331 if ( trimmed.compare( QLatin1String(
"HistoricalLocations" ), Qt::CaseInsensitive ) == 0 )
333 if ( trimmed.compare( QLatin1String(
"Datastreams" ), Qt::CaseInsensitive ) == 0 )
335 if ( trimmed.compare( QLatin1String(
"Sensors" ), Qt::CaseInsensitive ) == 0 )
337 if ( trimmed.compare( QLatin1String(
"ObservedProperties" ), Qt::CaseInsensitive ) == 0 )
339 if ( trimmed.compare( QLatin1String(
"Observations" ), Qt::CaseInsensitive ) == 0 )
341 if ( trimmed.compare( QLatin1String(
"FeaturesOfInterest" ), Qt::CaseInsensitive ) == 0 )
343 if ( trimmed.compare( QLatin1String(
"MultiDatastreams" ), Qt::CaseInsensitive ) == 0 )
356 return QStringLiteral(
"Things" );
358 return QStringLiteral(
"Locations" );
360 return QStringLiteral(
"HistoricalLocations" );
362 return QStringLiteral(
"Datastreams" );
364 return QStringLiteral(
"Sensors" );
366 return QStringLiteral(
"ObservedProperties" );
368 return QStringLiteral(
"Observations" );
370 return QStringLiteral(
"FeaturesOfInterest" );
372 return QStringLiteral(
"MultiDatastreams" );
386 return { QStringLiteral(
"id" ),
387 QStringLiteral(
"selfLink" ),
388 QStringLiteral(
"name" ),
389 QStringLiteral(
"description" ),
390 QStringLiteral(
"properties" ),
395 return { QStringLiteral(
"id" ),
396 QStringLiteral(
"selfLink" ),
397 QStringLiteral(
"name" ),
398 QStringLiteral(
"description" ),
399 QStringLiteral(
"properties" ),
404 return { QStringLiteral(
"id" ),
405 QStringLiteral(
"selfLink" ),
406 QStringLiteral(
"time" ),
411 return { QStringLiteral(
"id" ),
412 QStringLiteral(
"selfLink" ),
413 QStringLiteral(
"name" ),
414 QStringLiteral(
"description" ),
415 QStringLiteral(
"unitOfMeasurement" ),
416 QStringLiteral(
"observationType" ),
417 QStringLiteral(
"properties" ),
418 QStringLiteral(
"phenomenonTime" ),
419 QStringLiteral(
"resultTime" ),
424 return { QStringLiteral(
"id" ),
425 QStringLiteral(
"selfLink" ),
426 QStringLiteral(
"name" ),
427 QStringLiteral(
"description" ),
428 QStringLiteral(
"metadata" ),
429 QStringLiteral(
"properties" ),
434 return { QStringLiteral(
"id" ),
435 QStringLiteral(
"selfLink" ),
436 QStringLiteral(
"name" ),
437 QStringLiteral(
"definition" ),
438 QStringLiteral(
"description" ),
439 QStringLiteral(
"properties" ),
444 return { QStringLiteral(
"id" ),
445 QStringLiteral(
"selfLink" ),
446 QStringLiteral(
"phenomenonTime" ),
447 QStringLiteral(
"result" ),
448 QStringLiteral(
"resultTime" ),
449 QStringLiteral(
"resultQuality" ),
450 QStringLiteral(
"validTime" ),
451 QStringLiteral(
"parameters" ),
456 return { QStringLiteral(
"id" ),
457 QStringLiteral(
"selfLink" ),
458 QStringLiteral(
"name" ),
459 QStringLiteral(
"description" ),
460 QStringLiteral(
"properties" ),
465 return { QStringLiteral(
"id" ),
466 QStringLiteral(
"selfLink" ),
467 QStringLiteral(
"name" ),
468 QStringLiteral(
"description" ),
469 QStringLiteral(
"unitOfMeasurements" ),
470 QStringLiteral(
"observationType" ),
471 QStringLiteral(
"multiObservationDataTypes" ),
472 QStringLiteral(
"properties" ),
473 QStringLiteral(
"phenomenonTime" ),
474 QStringLiteral(
"resultTime" ),
486 fields.
append(
QgsField( QStringLiteral(
"id" ), QMetaType::Type::QString ) );
487 fields.
append(
QgsField( QStringLiteral(
"selfLink" ), QMetaType::Type::QString ) );
496 fields.
append(
QgsField( QStringLiteral(
"name" ), QMetaType::Type::QString ) );
497 fields.
append(
QgsField( QStringLiteral(
"description" ), QMetaType::Type::QString ) );
498 fields.
append(
QgsField( QStringLiteral(
"properties" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
503 fields.
append(
QgsField( QStringLiteral(
"name" ), QMetaType::Type::QString ) );
504 fields.
append(
QgsField( QStringLiteral(
"description" ), QMetaType::Type::QString ) );
505 fields.
append(
QgsField( QStringLiteral(
"properties" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
510 fields.
append(
QgsField( QStringLiteral(
"time" ), QMetaType::Type::QDateTime ) );
515 fields.
append(
QgsField( QStringLiteral(
"name" ), QMetaType::Type::QString ) );
516 fields.
append(
QgsField( QStringLiteral(
"description" ), QMetaType::Type::QString ) );
517 fields.
append(
QgsField( QStringLiteral(
"unitOfMeasurement" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
518 fields.
append(
QgsField( QStringLiteral(
"observationType" ), QMetaType::Type::QString ) );
519 fields.
append(
QgsField( QStringLiteral(
"properties" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
520 fields.
append(
QgsField( QStringLiteral(
"phenomenonTimeStart" ), QMetaType::Type::QDateTime ) );
521 fields.
append(
QgsField( QStringLiteral(
"phenomenonTimeEnd" ), QMetaType::Type::QDateTime ) );
522 fields.
append(
QgsField( QStringLiteral(
"resultTimeStart" ), QMetaType::Type::QDateTime ) );
523 fields.
append(
QgsField( QStringLiteral(
"resultTimeEnd" ), QMetaType::Type::QDateTime ) );
528 fields.
append(
QgsField( QStringLiteral(
"name" ), QMetaType::Type::QString ) );
529 fields.
append(
QgsField( QStringLiteral(
"description" ), QMetaType::Type::QString ) );
530 fields.
append(
QgsField( QStringLiteral(
"metadata" ), QMetaType::Type::QString ) );
531 fields.
append(
QgsField( QStringLiteral(
"properties" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
536 fields.
append(
QgsField( QStringLiteral(
"name" ), QMetaType::Type::QString ) );
537 fields.
append(
QgsField( QStringLiteral(
"definition" ), QMetaType::Type::QString ) );
538 fields.
append(
QgsField( QStringLiteral(
"description" ), QMetaType::Type::QString ) );
539 fields.
append(
QgsField( QStringLiteral(
"properties" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
544 fields.
append(
QgsField( QStringLiteral(
"phenomenonTimeStart" ), QMetaType::Type::QDateTime ) );
545 fields.
append(
QgsField( QStringLiteral(
"phenomenonTimeEnd" ), QMetaType::Type::QDateTime ) );
548 fields.
append(
QgsField( QStringLiteral(
"result" ), QMetaType::Type::QString ) );
550 fields.
append(
QgsField( QStringLiteral(
"resultTime" ), QMetaType::Type::QDateTime ) );
551 fields.
append(
QgsField( QStringLiteral(
"resultQuality" ), QMetaType::Type::QStringList, QString(), 0, 0, QString(), QMetaType::Type::QString ) );
552 fields.
append(
QgsField( QStringLiteral(
"validTimeStart" ), QMetaType::Type::QDateTime ) );
553 fields.
append(
QgsField( QStringLiteral(
"validTimeEnd" ), QMetaType::Type::QDateTime ) );
554 fields.
append(
QgsField( QStringLiteral(
"parameters" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
559 fields.
append(
QgsField( QStringLiteral(
"name" ), QMetaType::Type::QString ) );
560 fields.
append(
QgsField( QStringLiteral(
"description" ), QMetaType::Type::QString ) );
561 fields.
append(
QgsField( QStringLiteral(
"properties" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
566 fields.
append(
QgsField( QStringLiteral(
"name" ), QMetaType::Type::QString ) );
567 fields.
append(
QgsField( QStringLiteral(
"description" ), QMetaType::Type::QString ) );
568 fields.
append(
QgsField( QStringLiteral(
"unitOfMeasurements" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
569 fields.
append(
QgsField( QStringLiteral(
"observationType" ), QMetaType::Type::QString ) );
570 fields.
append(
QgsField( QStringLiteral(
"multiObservationDataTypes" ), QMetaType::Type::QStringList, QString(), 0, 0, QString(), QMetaType::Type::QString ) );
571 fields.
append(
QgsField( QStringLiteral(
"properties" ), QMetaType::Type::QVariantMap, QStringLiteral(
"json" ), 0, 0, QString(), QMetaType::Type::QString ) );
572 fields.
append(
QgsField( QStringLiteral(
"phenomenonTimeStart" ), QMetaType::Type::QDateTime ) );
573 fields.
append(
QgsField( QStringLiteral(
"phenomenonTimeEnd" ), QMetaType::Type::QDateTime ) );
574 fields.
append(
QgsField( QStringLiteral(
"resultTimeStart" ), QMetaType::Type::QDateTime ) );
575 fields.
append(
QgsField( QStringLiteral(
"resultTimeEnd" ), QMetaType::Type::QDateTime ) );
584 if ( expandedTypes.empty() )
591 path = ( path.isEmpty() ? QString() : ( path +
'_' ) ) +
qgsEnumValueToKey( expandedType );
593 for (
const QgsField &expandedField : expandedFields )
595 QgsField renamedExpandedField = expandedField;
596 renamedExpandedField.
setName( QStringLiteral(
"%1_%2" ).arg( path, expandedField.name() ) );
597 fields.
append( renamedExpandedField );
617 return QStringLiteral(
"location" );
620 return QStringLiteral(
"feature" );
623 return QStringLiteral(
"observedArea" );
674 QString geometryTypeString;
678 geometryTypeString = QStringLiteral(
"Point" );
681 geometryTypeString = QStringLiteral(
"Polygon" );
684 geometryTypeString = QStringLiteral(
"LineString" );
693 if ( filterTarget.isEmpty() )
696 return QStringLiteral(
"%1/type eq '%2' or %1/geometry/type eq '%2'" ).arg( filterTarget, geometryTypeString );
702 return ( extent.
isNull() || geometryField.isEmpty() )
704 : QStringLiteral(
"geo.intersects(%1, geography'%2')" ).arg( geometryField, extent.
asWktPolygon() );
709 QStringList nonEmptyFilters;
710 for (
const QString &filter : filters )
712 if ( !filter.isEmpty() )
713 nonEmptyFilters.append( filter );
715 if ( nonEmptyFilters.empty() )
717 if ( nonEmptyFilters.size() == 1 )
718 return nonEmptyFilters.at( 0 );
720 return QStringLiteral(
"(" ) + nonEmptyFilters.join( QLatin1String(
") and (" ) ) + QStringLiteral(
")" );
725 QNetworkRequest request = QNetworkRequest( QUrl( uri ) );
731 switch ( networkRequest.
get( request ) )
743 QString entityBaseUri;
747 auto rootContent = nlohmann::json::parse( content.
content().toStdString() );
748 if ( !rootContent.contains(
"value" ) )
750 QgsDebugError( QStringLiteral(
"No 'value' array in response" ) );
754 bool foundMatchingEntity =
false;
755 for (
const auto &valueJson : rootContent[
"value"] )
757 if ( valueJson.contains(
"name" ) && valueJson.contains(
"url" ) )
759 const QString name = QString::fromStdString( valueJson[
"name"].get<std::string>() );
761 if ( entityType == type )
763 const QString url = QString::fromStdString( valueJson[
"url"].get<std::string>() );
764 if ( !url.isEmpty() )
766 foundMatchingEntity =
true;
774 if ( !foundMatchingEntity )
780 catch (
const nlohmann::json::parse_error &ex )
782 QgsDebugError( QStringLiteral(
"Error parsing response: %1" ).arg( ex.what() ) );
786 auto getCountForType = [entityBaseUri, type, authCfg, feedback](
Qgis::GeometryType geometryType ) ->
long long
789 QString countUri = QStringLiteral(
"%1?$top=0&$count=true" ).arg( entityBaseUri );
792 if ( !typeFilter.isEmpty() )
793 countUri += QStringLiteral(
"&$filter=" ) + typeFilter;
795 const QUrl url( countUri );
797 QNetworkRequest request( url );
818 auto rootContent = nlohmann::json::parse( content.
content().toStdString() );
819 if ( !rootContent.contains(
"@iot.count" ) )
821 QgsDebugError( QStringLiteral(
"No '@iot.count' value in response" ) );
825 return rootContent[
"@iot.count"].get<
long long>();
827 catch (
const nlohmann::json::parse_error &ex )
829 QgsDebugError( QStringLiteral(
"Error parsing response: %1" ).arg( ex.what() ) );
835 QList<Qgis::GeometryType> types;
843 const long long matchCount = getCountForType( geometryType );
844 if ( matchCount < 0 )
846 else if ( matchCount > 0 )
847 types.append( geometryType );
939 switch ( relatedType )
961 switch ( relatedType )
981 switch ( relatedType )
1010 switch ( relatedType )
1034 switch ( relatedType )
1056 switch ( relatedType )
1079 switch ( relatedType )
1100 switch ( relatedType )
1122 switch ( relatedType )
1153 for (
int i = expansions.size() - 1; i >= 0 ; i-- )
1161 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 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 QgsFields fieldsForEntityType(Qgis::SensorThingsEntity type)
Returns the fields which correspond to 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)