15#ifndef QGSSENSORTHINGSUTILS_H
16#define QGSSENSORTHINGSUTILS_H
196 const QString &
orderBy = QString(),
197 Qt::SortOrder
sortOrder = Qt::SortOrder::AscendingOrder,
199 const QString &
filter = QString() );
317 SIP_PYOBJECT __repr__();
319 if ( !sipCpp->isValid() )
321 sipRes = PyUnicode_FromString(
"<QgsSensorThingsExpansionDefinition: invalid>" );
325 QString innerDefinition;
326 if ( !sipCpp->orderBy().isEmpty() )
328 innerDefinition = QStringLiteral(
"by %1 (%2)" ).arg( sipCpp->orderBy(), sipCpp->sortOrder() == Qt::SortOrder::AscendingOrder ? QStringLiteral(
"asc" ) : QStringLiteral(
"desc" ) );
330 if ( sipCpp->limit() >= 0 )
332 if ( !innerDefinition.isEmpty() )
333 innerDefinition = QStringLiteral(
"%1, limit %2" ).arg( innerDefinition ).arg( sipCpp->limit() );
335 innerDefinition = QStringLiteral(
"limit %1" ).arg( sipCpp->limit() );
337 if ( !sipCpp->filter().isEmpty() )
339 if ( !innerDefinition.isEmpty() )
340 innerDefinition = QStringLiteral(
"%1, filter '%2'" ).arg( innerDefinition ).arg( sipCpp->filter() );
342 innerDefinition = QStringLiteral(
"filter '%1'" ).arg( sipCpp->filter() );
345 QString str = QStringLiteral(
"<QgsSensorThingsExpansionDefinition: %1%2>" ).arg(
qgsEnumValueToKey( sipCpp->childEntity() ), innerDefinition.isEmpty() ? QString() : ( QStringLiteral(
" " ) + innerDefinition ) );
346 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
355 Qt::SortOrder mSortOrder = Qt::SortOrder::AscendingOrder;
SensorThingsEntity
OGC SensorThings API entity types.
@ Invalid
An invalid/unknown entity.
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
RelationshipCardinality
Relationship cardinality.
WkbType
The WKB type describes the number of dimensions a geometry has.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Container of fields for a vector layer.
A rectangle specified with double values.
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.
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...
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.
Utility functions for working with OGC SensorThings API services.
static constexpr int DEFAULT_EXPANSION_LIMIT
Default limit on number of expanded features fetched.
static QStringList propertiesForEntityType(Qgis::SensorThingsEntity type)
Returns the SensorThings properties which correspond to a specified entity type.
static constexpr int DEFAULT_PAGE_SIZE
Default page size.
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 constexpr int DEFAULT_FEATURE_LIMIT
Default limit on number of features fetched.
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.
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)