qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.59k stars 3.01k forks source link

Inconsistent use of namedlayer/userlayer when exporting sld from grid layer or vector layer #57789

Open pvgenuchten opened 4 months ago

pvgenuchten commented 4 months ago

Feature description

Inconsistent use of namedlayer/userlayer when exporting sld from grid layer and vector layer. When sld from vector layer is exported the namedlayer element is correctly applied, when exporting from grid layer, the UserLayer element in incorrectly used.

The different behavior seems related to the use of SLD 1.0 vs SLD 1.1 for grid layers at https://github.com/qgis/QGIS/blob/38e955291af9d45ef04795adf080c698dd3c2e30/src/core/qgsmaplayer.cpp#L2203-L2216

When reading the sld spec, but also in the 1.0 spec:

11.3 User-defined layers
In addition to using named layers, it is also useful to be able to define custom userdefined layers for rendering. The Schema fragment for user-defined layers is as follows:

My impression is that QGIS incorrectly uses the userlayer element for grid layers in generated SLD when exporting SLD 1.0 for a grid layer. The 'namedlayer' element seems more appropriate.

Additional context

At the moment Mapserver is not able to render SLD's exported from grids in QGIS, because it only supports the namedLayer element in SLD.

dgva commented 3 months ago

Also suffering from this. Adding to this, when loading into GeoServer, it can't be validated, thus, can't use the style.