AirBreak-UIA / SensorThingsAPI_QGIS-plugin

Plugin enabling QGIS software (www.qgis.org) to access dynamic data from sensors, using SensorThings API protocol (https://www.ogc.org/standards/sensorthings)
Other
8 stars 6 forks source link

Handle STA v1.0 services #4

Open rduivenvoorde opened 1 year ago

rduivenvoorde commented 1 year ago

In NL there is a public v1.0 STA service. It is based on: https://github.com/gost/server.

Because I thought to be able to make the plugin maybe backwards compatible I tried to debug and fix stuff. But I fail to debug the Python/Javascript bridges.

The URL: https://api-samenmeten.rivm.nl/v1.0/Locations

On https://github.com/AirBreak-UIA/SensorThingsAPI_QGIS-plugin/blob/main/providers/provider_frost.py#L289 I changed

query.addQueryItem('$orderby', '@iot.id+asc')

to

            # RD: not sure, but GOST 1.0 does not return values if using @iot.id+asc, so this COULD be a GOST only hack:
            if 'v1.0' in url.path():
                query.addQueryItem('$orderby', 'id+asc')
            else:
                query.addQueryItem('$orderby', '@iot.id+asc')

to be able to at least see the locations.

But, though there is a link to Observations in Sensor: https://api-samenmeten.rivm.nl/v1.0/Datastreams(7343)/Sensor

The 'Open Measurements dialog' button in the table is never available.

Crux seems to be this line: https://github.com/AirBreak-UIA/SensorThingsAPI_QGIS-plugin/blob/main/html/templates/js/location.js#L215

As there is (apparently, not sure if this is GOST specific, or v1.0 specific) never a phenomenonTime field in the Datastream object: https://api-samenmeten.rivm.nl/v1.0/Datastreams(7343)

By disabling that check, I'm able to at least get the button, but after that I'm stuck, as I fail to be able to debug/step through the javascript/jinja2 template code (using Pycharm Professional, here with 'Python Debug Server' debugging.

So I'm wondering what is an easy way to debug this.

Note: my hope is to show this plugin to the owner of the service and convince them to move to Frost/newer STA versions...

Any hints appreciated.

rduivenvoorde commented 1 year ago

Ah my colleague Matteo just pointed to QWebSettings.DeveloperExtrasEnabled so you can make the Debug view availble for QWebView... Which I find here: https://github.com/AirBreak-UIA/SensorThingsAPI_QGIS-plugin/blob/main/sensor_things_browser.py#L259

So I should 'just' make sure __PLG_DEBUG__ == True :-)

See: https://github.com/AirBreak-UIA/SensorThingsAPI_QGIS-plugin/blob/main/__init__.py#L8