Closed NyakudyaA closed 4 years ago
@dmarteau Should we move this issue to https://github.com/3liz/py-qgis-server ?
Please move the issue to the appropriate project...
Please move the issue to the appropriate project...
There is a button for that ;-)
This is not related to Lizmap @NyakudyaA
@NyakudyaA: py-qgis-server use the official qgis debian distribution https://www.qgis.org/en/site/forusers/alldownloads.html#debian-ubuntu and is a python layer over the qgis server API.
I don't know how it differs from the camptocamp image since I couldn't find their Dockerfile, but as we pass all requests to the API, it may be a problem with the official distro. We need to check it out...
Thanks @Gustry i was printing initially from lizmap webclient then noticed this behavior. I then setup the individual containers to try to debug what was happening
@rldhont @Gustry An Idea why qgis would not evaluate function ?
@NyakudyaA Did you try a GetMap request ?
@NyakudyaA Did you try a GetMap request ?
getmap request are working fine
@NyakudyaA: py-qgis-server use the official qgis debian distribution https://www.qgis.org/en/site/forusers/alldownloads.html#debian-ubuntu and is a python layer over the qgis server API.
I don't know how it differs from the camptocamp image since I couldn't find their Dockerfile, but as we pass all requests to the API, it may be a problem with the official distro. We need to check it out...
You can also try to run the https://github.com/gem/oq-qgis-server. It has a Dockerfile visible and correctly evaluates as well
getmap request are working fine
Interesting, so its seems that expressions are not evaluated only in the context of a getprint
You can also try to run the https://github.com/gem/oq-qgis-server. It has a Dockerfile visible and correctly evaluates as well
@NyakudyaA Thx for the tip, also there is no différence the way Qgis is installed, the only difference is how the server is run:
I suspect a missing configuration that would prevent getprint to evaluate function in the context of the server.
@rldhont @Gustry I found that: if the we create the project from the QgsConfigCache then the getPrint evaluate correctly the function but if we create the project explicitely with QgsProject() then the getPrint does not evaluate functions.
So
settings = QgsServerSettings()
project = QgsConfigCache.instance().project( config_path, settings )
server.handleRequest(request, response, project=project)
does lead to correct getPrint() request, while
project = QgsProject()
project.read( config_path )
server.handleRequest(request, response, project=project)
will occurs in incorrect getPrint().
Looking at the 3.10 source code of QgsConfigCache, the cache does nothing more (except for bad layer handler): So I suspect that the getPrint() code use the default config cache at some point. @rldhont @Gustry any clue ?
@rldhont @Gustry I think I have found the problem: the QgsConfigCache do QgsProject::setInstance(...)
, I suspect that
some internal qgis still use the QgsProject::instance
method (seems to be removed since Qgis 3.15).
If you instanciate the QgsProject and pass it to the server then you bypass the QgsConfigCache and the setInstance
is never called. Infortunatly this method is not accessible from python, so this defeat the purpose to explicitely pass a QgsProject to the handleRequest
method.
We need to make a PR to fix the problem so that QgsProject::setInstance
is called whe we pass a project or eventually expose the setInstance method.
Remember that we do not use the QgsConfigCache because is does support nothing else that project files - and we want to support alternative storage (aka postgres storage)
I confirm that running a qgis server with patch applied to call QgsProject:setInstance()
solve the problem.
@rldhont can you call for review https://github.com/qgis/QGIS/pull/38488 ?
The fix has been accepted and backported to 3.10 and 3.14
@NyakudyaA we wait for the next qgis minor release to confirm the fix.
The fix has been accepted and backported to 3.10 and 3.14
* [qgis/QGIS#38508](https://github.com/qgis/QGIS/pull/38508) * [qgis/QGIS#38509](https://github.com/qgis/QGIS/pull/38509)
@NyakudyaA we wait for the next qgis minor release to confirm the fix.
Thanks a lot for spotting the bug. I will wait for the bugfix and then test
Fixed and backported to qgis 3.10
Procedure 3liz qgis server image
Print Request http://localhost:8091/ows/?DPI=100&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=pdf&LAYERS=index1in50k,ProvincialBoundary_sae&MAP=liz/error.qgs&MAP0:EXTENT=2972996.901597,-3761252.0445,3009497.779341,-3739151.513044&MAP0:GRID_INTERVAL_X=5000&MAP0:GRID_INTERVAL_Y=5000&MAP0:LAYERS=ProvincialBoundary_sae&MAP0:SCALE=100000&MAP0:STYLES=default,default&OPACITIES=255,255&REQUEST=GetPrint&SERVICE=WMS&SRS=EPSG:3857&STYLES=default,default&TEMPLATE=map&TRANSPARENT=true&VERSION=1.3.0
Print Request Image
Image version
Procedure camp to camp image
Print Request http://localhost:8380/ows/?DPI=100&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=pdf&LAYERS=index1in50k,ProvincialBoundary_sae&MAP=/etc/qgisserver/error.qgs.qgs&MAP0:EXTENT=2972996.901597,-3761252.0445,3009497.779341,-3739151.513044&MAP0:GRID_INTERVAL_X=5000&MAP0:GRID_INTERVAL_Y=5000&MAP0:LAYERS=ProvincialBoundary_sae&MAP0:SCALE=100000&MAP0:STYLES=default,default&OPACITIES=255,255&REQUEST=GetPrint&SERVICE=WMS&SRS=EPSG:3857&STYLES=default,default&TEMPLATE=map&TRANSPARENT=true&VERSION=1.3.0
Print Request Image
liz.zip