qgis / qwc2-demo-app

QWC2 demo application
Other
240 stars 149 forks source link

Imprecision on scale dependant rendering #556

Open cazitouni opened 3 weeks ago

cazitouni commented 3 weeks ago

Hello @manisandro,

Today I encounter a problem using QWC. For example if I make a map that render some layer at a scale 1:25000 and hide some ohter at the same scale the rendering will not work on QWC at 96DPI I have to use the wmsdpi params with a dpi = 96.001, which seems very odd. (same problem goes for other scales as well it's not 1:25000 related)

For example loading a project that make this get map request for a scale 1:25000 :

https://viewer.wisiglw.cus.fr/qgis/refer_fond_gris?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=2043727.4105137712,7272555.275401148,2056374.4938471047,7279011.108734482&CRS=EPSG:3948&WIDTH=1912&HEIGHT=976&LAYERS=refer_fond_gris&STYLES=&FORMAT=image/png&DPI=96&TRANSPARENT=TRUE

will render the map improperly like this

image

while loading the same project request with a wmsdpi of 90.001 will render the map correctly

https://viewer.wisiglw.cus.fr/qgis/refer_fond_gris?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=2043727.4105137712,7272555.275401148,2056374.4938471047,7279011.108734482&CRS=EPSG:3948&WIDTH=1912&HEIGHT=976&LAYERS=refer_fond_gris&STYLES=&FORMAT=image/png&DPI=96.001&TRANSPARENT=TRUE

image

Also, loading the wms from qgis server to qgis desktop works great with a rounded 96 DPI. The only difference I was able to spot during my testing is the bbox having 12 digits in qgis instead of 10 in QWC, maybe it's an imprecision thing ? But it seems strange as well.

Also problem seems to be the same when using print service with the layer loaded as an external wms.

I will continue to look at it, but I'm kinda clueless for now, if you have any lead I'll apreciate.

Thanks you in advance for your answer. Kind regards, Clément.

cazitouni commented 1 week ago

Hello @manisandro,

No idea about that one ?

Thanks again, Rergards, Clément.

manisandro commented 1 week ago

At a first glance I'd say this could be because QGIS Server internally recomputes the scale based on the geographic bounding box, the dpi and the rendering pixel size, and the result may be slightly different than the scale displayed in the web client.

cazitouni commented 1 week ago

Yes Qgis server seems to use bbox, height, width and dpi to compute the scale, but the thing is that in desktop the scale is rendered corectly using 96 dpi but not in the web client. The request I've linked above is the way the client call the Qgis server.

Maybe the bbox computed by the client is a bit off compared to the one computed by a Qgis Desktop.

Using 96.001 is not a problem using the webclient without print template, but when tyou try to print it'll print with a 96 like dpi and the scale will be off again.

It would be nice if the web client would render the wms the same way as a Qgis desktop regarding the scale.

I'll try to look into it as well.