29QgsSensorThingsRootItem::QgsSensorThingsRootItem(
QgsDataItem *parent, QString name, QString path )
33 mIconName = QStringLiteral(
"mIconSensorThings.svg" );
37QVector<QgsDataItem *> QgsSensorThingsRootItem::createChildren()
39 QVector<QgsDataItem *> connections;
41 for (
const QString &connName : connectionList )
43 QgsDataItem *conn =
new QgsSensorThingsConnectionItem(
this, connName, mPath +
'/' + connName );
44 connections.append( conn );
53QgsSensorThingsConnectionItem::QgsSensorThingsConnectionItem(
QgsDataItem *parent,
const QString &name,
const QString &path )
57 mIconName = QStringLiteral(
"mIconConnect.svg" );
64bool QgsSensorThingsConnectionItem::equal(
const QgsDataItem *other )
66 const QgsSensorThingsConnectionItem *o = qobject_cast<const QgsSensorThingsConnectionItem *>( other );
67 return ( type() == other->
type() && o && mPath == o->mPath && mName == o->mName );
70QVector<QgsDataItem *> QgsSensorThingsConnectionItem::createChildren()
72 QVector<QgsDataItem *> children;
77 QgsSensorThingsProvider::SENSORTHINGS_PROVIDER_KEY, uri );
91 QVariantMap entityUriParts = connectionUriParts;
96 children.append(
new QgsSensorThingsEntityContainerItem(
this,
99 entityUriParts, entity, mConnName ) );
103 children.append(
new QgsSensorThingsLayerEntityItem(
this,
107 QgsSensorThingsProvider::SENSORTHINGS_PROVIDER_KEY,
120QgsSensorThingsEntityContainerItem::QgsSensorThingsEntityContainerItem(
QgsDataItem *parent,
const QString &name,
const QString &path,
const QVariantMap &entityUriParts,
Qgis::SensorThingsEntity entityType,
const QString &connectionName )
122 , mEntityUriParts( entityUriParts )
123 , mEntityType( entityType )
124 , mConnectionName( connectionName )
130bool QgsSensorThingsEntityContainerItem::equal(
const QgsDataItem *other )
132 const QgsSensorThingsEntityContainerItem *o = qobject_cast<const QgsSensorThingsEntityContainerItem *>( other );
133 return ( type() == other->
type() && o && mPath == o->mPath && mName == o->mName );
136QVector<QgsDataItem *> QgsSensorThingsEntityContainerItem::createChildren()
138 QVector<QgsDataItem *> children;
149 QVariantMap geometryUriParts = mEntityUriParts;
155 geometryUriParts.insert( QStringLiteral(
"geometryType" ), QStringLiteral(
"point" ) );
156 name = tr(
"Points" );
160 geometryUriParts.insert( QStringLiteral(
"geometryType" ), QStringLiteral(
"multipoint" ) );
161 name = tr(
"MultiPoints" );
165 geometryUriParts.insert( QStringLiteral(
"geometryType" ), QStringLiteral(
"line" ) );
166 name = tr(
"Lines" );
170 geometryUriParts.insert( QStringLiteral(
"geometryType" ), QStringLiteral(
"polygon" ) );
171 name = tr(
"Polygons" );
177 children.append(
new QgsSensorThingsLayerEntityItem(
this,
181 QgsSensorThingsProvider::SENSORTHINGS_PROVIDER_KEY,
182 layerType, mEntityType, mConnectionName ) );
183 children.last()->setSortKey( sortKey++ );
193QgsSensorThingsLayerEntityItem::QgsSensorThingsLayerEntityItem(
QgsDataItem *parent,
const QString &name,
const QString &path,
196 QgsProviderRegistry::instance()->encodeUri( QgsSensorThingsProvider::SENSORTHINGS_PROVIDER_KEY, uriParts ),
198 , mUriParts( uriParts )
199 , mEntityType( entityType )
200 , mConnectionName( connectionName )
205QString QgsSensorThingsLayerEntityItem::layerName()
const
210 const QString geometryType = mUriParts.value( QStringLiteral(
"geometryType" ) ).toString();
211 QString geometryNamePart;
212 if ( geometryType.compare( QLatin1String(
"point" ), Qt::CaseInsensitive ) == 0 ||
213 geometryType.compare( QLatin1String(
"multipoint" ), Qt::CaseInsensitive ) == 0 )
215 geometryNamePart = tr(
"Points" );
217 else if ( geometryType.compare( QLatin1String(
"line" ), Qt::CaseInsensitive ) == 0 )
219 geometryNamePart = tr(
"Lines" );
221 else if ( geometryType.compare( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) == 0 )
223 geometryNamePart = tr(
"Polygons" );
226 if ( !geometryNamePart.isEmpty() )
228 baseName = QStringLiteral(
"%1 - %2 (%3)" ).arg( mConnectionName,
234 baseName = QStringLiteral(
"%1 - %2" ).arg( mConnectionName,
240 baseName = QStringLiteral(
"%1 - %2" ).arg( mConnectionName,
251QString QgsSensorThingsDataItemProvider::name()
253 return QStringLiteral(
"SensorThings" );
256QString QgsSensorThingsDataItemProvider::dataProviderKey()
const
258 return QStringLiteral(
"sensorthings" );
266QgsDataItem *QgsSensorThingsDataItemProvider::createDataItem(
const QString &path,
QgsDataItem *parentItem )
268 if ( path.isEmpty() )
269 return new QgsSensorThingsRootItem( parentItem, QObject::tr(
"SensorThings" ), QStringLiteral(
"sensorthings:" ) );
@ NetworkSources
Network/internet source.
@ Populated
Children created.
@ Collapse
The collapse/expand status for this items children should be ignored in order to avoid undesired netw...
@ Fast
CreateChildren() is fast enough to be run in main thread when refreshing items, most root items (wms,...
QFlags< DataItemProviderCapability > DataItemProviderCapabilities
Capabilities for data item providers.
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...
@ ObservedProperty
An ObservedProperty specifies the phenomenon of an Observation.
@ 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...
BrowserLayerType
Browser item layer types.
@ Point
Vector point layer.
@ Polygon
Vector polygon layer.
@ TableLayer
Vector non-spatial layer.
WkbType
The WKB type describes the number of dimensions a geometry has.
@ MultiPolygon
MultiPolygon.
@ MultiLineString
MultiLineString.
A Collection that represents a root group of connections from a single data provider.
A Collection: logical collection of layers or subcollections, e.g.
Base class for all items in the model.
Qgis::BrowserItemType type() const
Item that represents a layer that can be opened with one of the providers.
A registry / canonical manager of data providers.
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
static QString encodedLayerUri(const Data &data)
Returns connection data encoded as a string containing a URI for a SensorThings vector data provider.
static QStringList connectionList()
Returns a list of the stored connection names.
static Data connection(const QString &name)
Returns connection details for the stored connection with the specified name.
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.
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
Represents decoded data of a SensorThings connection.