qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.37k stars 2.98k forks source link

[sensorthings] follow navigationlinks and add links to attribute table #56805

Closed pvgenuchten closed 6 months ago

pvgenuchten commented 6 months ago

Feature description

Sensorthings adds to each type (sensor, location, datastream) a set of navigationlinks which enable linkage between the types, actually one needs to follow the link to retrieve the actual identifier of the linked entity, or use the $expand option on the query to expand the basic query with additional types.

https://airquality-frost.k8s.ilt-dmz.iosb.fraunhofer.de/v1.1/Datastreams?$expand=Observations&$top=10

Qgis currently does not include these navigation links in the attribute table, which makes it hard to link datastreams to their related location and observations

Some samples:

https://airquality-frost.k8s.ilt-dmz.iosb.fraunhofer.de/v1.1/Sensors(15424)

{
    "@iot.selfLink": "https://airquality-frost.k8s.ilt-dmz.iosb.fraunhofer.de/v1.1/Sensors(15424)",
...
    "Datastreams@iot.navigationLink": "https://airquality-frost.k8s.ilt-dmz.iosb.fraunhofer.de/v1.1/Sensors(15424)/Datastreams",
    "MultiDatastreams@iot.navigationLink": "https://airquality-frost.k8s.ilt-dmz.iosb.fraunhofer.de/v1.1/Sensors(15424)/MultiDatastreams"
}

https://airquality-frost.k8s.ilt-dmz.iosb.fraunhofer.de/v1.1/Datastreams(19801)

{
    "@iot.selfLink": "https://airquality-frost.k8s.ilt-dmz.iosb.fraunhofer.de/v1.1/Datastreams(19801)",
...
    "ObservedProperty@iot.navigationLink": "https://airquality-frost.k8s.ilt-dmz.iosb.fraunhofer.de/v1.1/Datastreams(19801)/ObservedProperty",
    "Sensor@iot.navigationLink": "https://airquality-frost.k8s.ilt-dmz.iosb.fraunhofer.de/v1.1/Datastreams(19801)/Sensor",
    "Thing@iot.navigationLink": "https://airquality-frost.k8s.ilt-dmz.iosb.fraunhofer.de/v1.1/Datastreams(19801)/Thing",
    "Observations@iot.navigationLink": "https://airquality-frost.k8s.ilt-dmz.iosb.fraunhofer.de/v1.1/Datastreams(19801)/Observations"
}

image

Suggestion would be to include the navigationlinks as column(s) to the attribute table, either as a json string like the properties snippet, or as an array by link type

Additional context

Sensorthings spec

This would enable me to add locations, things, datastreams and observations to my project and link them using joins, location has the coordinates, observations contains the actual measured values. I can even use the (latest) value in observation to style the icon of the location.

pvgenuchten commented 6 months ago

Other option here would be to enable a multiselect on the Entity type in the sensorthings data source manager

image

QGIS would $expand the query with the selected entity types (which would be the main type?)

The result would be a hierarchical object of the main type and its children, is QGIS able to visualise such a data structure in the attribute table?

The logic behind user selection of main and subtypes is that every sensorthings API is different, some have a focus on feature-of-interest, some on location.

In order to prevent loading the full database it is important to limit the result by filters, or else a max number ($top). Providing user friendly filter options may be challenging, because filters may apply at any level (observation/result > 0, location/geometry within map bounds, observedProperty/name = 'FE')

nyalldawson commented 6 months ago

@pvgenuchten this is on it's way for 3.38 :+1:

pvgenuchten commented 6 months ago

Nice! Always available to test/share thoughts..

sgrellet commented 5 months ago

Thanks Paul for testing and providing this idea, feel free to add some more and spread the word :)