[QGIS-Developer] QGIS-Server reload raster layer on request

Clemens Rudert clemens at opengis.ch
Wed Jun 29 07:10:53 PDT 2022


Hi QGIS-Server-Devs

its about QGIS-Server 3.22

I have a project served by QGIS-Server containing 70-80 raster and vector
layers from http sources. These sources are dynamic and not under my
control. Lets say http://dummy.com/geo.tif or http://dummy.com/geo.json.
The content of these tif/json changes over time. So I need QGIS-Server to
reload it on every request I send to the WMS. I came up with the idea of a
plugin. The idea of acting based on passed layers url param and on
dedicated layers comes from the really bad loading speed of this project.
So reinitializing the project on request is no solution.
My current plugin does work fine for vector layers. On every request I call

layer.dataProvider().reloadData()

and the vector data is freshly fetched from the server as expected.

However this is not working for raster layers. It is my understanding that
GDAL is used as dataProvider. It has no effect if i call reload on the
QgsRasterLayer or reloadData on the QgsRasterDataProvider. It simply does
not have any effect.

I already invested quite a time and found these places of info:
https://gis.stackexchange.com/questions/294675/changing-uri-source-of-wms-raster-layer-in-place-pyqgis

https://gis.stackexchange.com/questions/159950/making-qgis-layer-update-from-changed-data-source

I stumbled over this QGIS-Desktop-Plugin wich works nice and does what I
want. It resuts in a valid updated raster layer without changing the
QgsRasterLayer Object layer:
https://github.com/enricofer/changeDataSource/blob/master/setdatasource.py#L175

Despite the fact that this way of manipulating the DOM seem not work on
server because running my plugin for raster layers crashes QGIS-Server
process and I do not get any info what might be wrong (it runs with
loglevel 0). I would be happy to get some suggestions on what might be
wrong here. You can find my current WIP state here:
https://github.com/opengisch/qgis-layer-tweak/blob/master/tweak_server.py

Sorry for the long description.

I hope you can give me directions.

Cheers Clemens

-- 
 <https://qfield.org/get/>

QFIELD 2.0 IS HERE! - Hold the power of QGIS in 
your hand - learn more 
<https://www.opengis.ch/2022/04/05/qfield-2-0-is-here/> - get it now 
<https://qfield.org/get>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20220629/eb58e143/attachment-0001.htm>


More information about the QGIS-Developer mailing list