qgis / qwc2-demo-app

QWC2 demo application
Other
240 stars 149 forks source link

Print and map export does not work correct with multi style layers #525

Closed danceb closed 4 months ago

danceb commented 4 months ago

The new function for providing/selecting multiple layer styles does not work properly with printing and the map export plugin. There are different issues here:

manisandro commented 4 months ago

Can you provide more details? (Stacktraces, request error responses, ...)? I can successfully print/export a project with multiple multi-style layers here.

danceb commented 4 months ago

The issue is, that it mixes the styles here, if an external wms layer (the background layer for instance) should be printed as well. While printing it tries to apply the style to another layer, from whom the style is not part of. From the log:

qwc-ogc-service_1              |   LAYERS = EXTERNAL_WMS:A,Flurstücke
[...]
qwc-ogc-service_1              |   STYLES = Umrandung und Beschriftung rot,
[...]
qwc-ogc-service_1              |   A:URL = https://ows.jena.de/mapproxy/wms
qwc-ogc-service_1              |   A:LAYERS = Stadtplan_300
qwc-ogc-service_1              |   A:STYLES = 
[...]
qwc-ogc-service_1              |   MAP0:LAYERS = EXTERNAL_WMS:A,Flurstücke
qwc-ogc-service_1              |   MAP0:STYLES = Umrandung und Beschriftung rot
[...]
qwc-qgis-server_1              | <ServiceExceptionReport version="1.3.0" xmlns="http://www.opengis.net/ogc">
qwc-qgis-server_1              |  <ServiceException code="StyleNotDefined">Style 'Umrandung und Beschriftung rot' does not exist for layer 'A'</ServiceException>
qwc-qgis-server_1              | </ServiceExceptionReport>

So the style Umrandung und Beschriftung rot is actually a style from the layer Flurstücke, but it tries to apply this on layer A, which is the external background layer for printing.

The same here with multiple layers with named styles:

qwc-ogc-service_1              |   LAYERS = EXTERNAL_WMS:A,Flurstücke,Flur
[...]
qwc-ogc-service_1              |   STYLES = Umrandung und Beschriftung rot,blaue Umrandung,
[...]
qwc-ogc-service_1              |   A:URL = https://ows.jena.de/mapproxy/wms
qwc-ogc-service_1              |   A:LAYERS = Stadtplan_300
qwc-ogc-service_1              |   A:STYLES = 
[...]
qwc-ogc-service_1              |   MAP0:LAYERS = EXTERNAL_WMS:A,Flurstücke,Flur
qwc-ogc-service_1              |   MAP0:STYLES = Umrandung und Beschriftung rot,blaue Umrandung
[...]
qwc-qgis-server_1              | <ServiceExceptionReport version="1.3.0" xmlns="http://www.opengis.net/ogc">
qwc-qgis-server_1              |  <ServiceException code="StyleNotDefined">Style 'blaue Umrandung' does not exist for layer 'Flurstücke'</ServiceException>
qwc-qgis-server_1              | </ServiceExceptionReport>

Here it tries to apply the style blaue Umrandung to layer Flurstücke but its actually a part of the layer Flur.

The mapping from styles and layers seems to work correctly if no external layer is included in the printing request.

I couldn't reproduce the third case anymore, that the map is printed but with the wrong style, but I think it is related to the issue mentioned here.

manisandro commented 4 months ago

Thanks, this should be fixed by https://github.com/qgis/qwc2/commit/917c25354bd311a2907e48d90c2ca26bbb482df0