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.36k stars 2.98k forks source link

[SensorThings] FeaturesOfInterest not show on map and throwing json exception: type must be string, but is array #57577

Closed rduivenvoorde closed 3 months ago

rduivenvoorde commented 3 months ago

What is the bug or the crash?

Requesting 'FeaturesOfInterest' and expanding the 'Observations' of these, throw an exception:

Screenshot from 2024-05-27 14-23-54

I think (!?) this is related to the fact that QGIS (or the SensorThings provider), thinks that an Observation result always is a scalar value, being a number or a string.

But the specs also define so called 'MultiDatastreams', in which the result then consists of an array of values.

Another option (as the type of 'Observation/result' is 'any') is actually that the result value is json itself (in our case it is a geojson object).

Both these options should be handled (dirty hack: just create a string of them...)

Steps to reproduce the issue

See the screendump in which I connect to the public sta service on:

https://airquality-frost.k8s.ilt-dmz.iosb.fraunhofer.de/v1.1/

The zoom in (for example to Utrecht in The Netherlands) to have just a few locations, and then request for FeaturesOfInterest and expand the Observations (again, see screendump).

You should now see Points on the map (like you seen without the expansion), but you do NOT see points.

Another observation is that if you try to open the Attribute Table, you get the json parse exception (visible in the screendump).

For reference: this is the url with data retrieved:

https://airquality-frost.k8s.ilt-dmz.iosb.fraunhofer.de/v1.1/FeaturesOfInterest?$top=9948&$count=false&$expand=Observations($top=100)&$filter=(feature/type eq 'Point' or feature/geometry/type eq 'Point') and (geo.intersects(feature, geography'Polygon ((5.12173000000000034 52.10079999999999956, 5.13339999999999996 52.10079999999999956, 5.13339999999999996 52.10660000000000025, 5.12173000000000034 52.10660000000000025, 5.12173000000000034 52.10079999999999956))'))

image

I think it is because the result is an array (because it is a Multidatastream), see above and link below:

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

As said: my actual use-case is that the result is a json. Not sure how to handle this, but it should not throw a parse exception, but it could show the json as a string?

Versions

QGIS version 3.37.0-Master QGIS code revision a6a32bd1fd9
Qt version 5.15.10
Python version 3.11.9
GDAL/OGR version 3.8.5
PROJ version 9.4.0
EPSG Registry database version v11.004 (2024-02-24)
GEOS version 3.12.1-CAPI-1.18.1
SQLite version 3.45.3
PostgreSQL client version 16.3 (Debian 16.3-1)
SpatiaLite version 5.1.0
QWT version 6.1.4
QScintilla2 version 2.14.1
OS version Debian GNU/Linux trixie/sid
       

This copy of QGIS writes debugging output.   |   |   |   Active Python plugins SensorThingsAPI | 1.1.12 pdokservicesplugin | 5.0.1 QuickWKT | 3.1 db_manager | 0.1.20 grassprovider | 2.12.99 processing | 2.12.99 MetaSearch | 0.3.6

Supported QGIS version

New profile

Additional context

No response

nyalldawson commented 3 months ago

@rduivenvoorde https://github.com/qgis/QGIS/pull/57583 fixes this, but because we can't dynamically change the field value type based on the actual value for each feature, i've had to resort to using just a comma separated string for the multiple values