[MapServer-dev] RFC 138 - Reference SLD files in Mapfiles

Seth G sethg at geographika.co.uk
Sat Feb 10 01:48:30 PST 2024


Hi Even,

Thanks for the excellent feedback. I'll update the RFC to reflect these. 

As you wrote multiple named layers in an SLD could be handled in one of two ways:

1. Add a warning to the logs, and apply the first NamedLayer in the file. Simplest but least flexible. 
2. Check if any of the SLD names match the LAYER name and apply this. If no match is found, emit a warning in the logs,
and apply the first NamedLayer. 

The second option would allow multiple layers in the Mapfile to reuse the same SLD file, but could become harder to maintain - if either the Mapfile name is changed or the SLD names are modified users may be left confused as to why styling has changed. Interested to hear others' views, and which might work best with QGIS and GeoServer. 

> - I was also wondering how much necessary it was to have the empty CLASS 
> END block. Perhaps it could be implied if STYLEITEM 
> "sld://mysldfile.xml"  is found? Would be a bit more user friendly (and 
> what would happen if CLASS is there but not empty? should we allow that?)

I added this as the JavaScript implementation worked this way, so I thought there may be a good reason for this e.g. large refactors to support a layer without a class. If this is not the case then the empty class can be left out, and I could add a debug log message warning if any classes are present in the layer. A future option could be to allow URLs to SLD files in the STYLEITEM, and in that case a CLASS might be useful as a fallback if the URL request fails. This won't be part of this RFC however. 

> - If the user issues a GetStyle WMS layer... I guess they won't get the 
> original SLD from the STYLEIDEM, but one that will have be generated 
> from MapServer styling objects ? As the SLD -> MapServer styling could 
> be lossy, perhaps that could be noted in the user doc.

Yes I'll add a note about this in the docs. There are quite a few "what if" scenarios related to applying SLDs, even in the current implementations. I'll try to improve the test coverage around these so at least the behaviour is defined and known. 

Seth

--
web:https://geographika.net & https://mapserverstudio.net
twitter: @geographika

On Sat, Feb 10, 2024, at 12:27 AM, Even Rouault wrote:
> Hi Seth,
>
> Looks good. +1
>
> Small details and questions:
>
> - "If multiple NamedLayers are contained in the SLD file only the first 
> will be used." : perhaps emit a warning/debug message when there are 
> more than 1 NamedLayer?
>
> - I was wondering about the scenario where someone would have a single 
> SLD with named layers A and B, and the mapfile would have also layers A 
> and B. In that situation, I guess we would want the A <--> A and B <--> 
> B matching.  Perhaps the logic could be "if a SLD has several 
> NamedLayer, then try to find one whose name matches the MapServer LAYER 
> name, and if not just pick up the first one"?  I'm not too strong about 
> that though.
>
> - I was also wondering how much necessary it was to have the empty CLASS 
> END block. Perhaps it could be implied if STYLEITEM 
> "sld://mysldfile.xml"  is found? Would be a bit more user friendly (and 
> what would happen if CLASS is there but not empty? should we allow that?)
>
> - If the user issues a GetStyle WMS layer... I guess they won't get the 
> original SLD from the STYLEIDEM, but one that will have be generated 
> from MapServer styling objects ? As the SLD -> MapServer styling could 
> be lossy, perhaps that could be noted in the user doc.
>
> Even
>
> Le 10/02/2024 à 00:03, Seth G via MapServer-dev a écrit :
>> Hi all,
>>
>> I've added a new RFC - MS RFC 138: Reference SLD files in Mapfiles at https://mapserver.org/development/rfc/ms-rfc-138.html
>> This would allow SLD files to be referenced in a Mapfile using the STYLEITEM (similar to how JS files are referenced):
>>
>>      LAYER
>>        STYLEITEM "sld://mysldfile.xml" # uses SHAPEPATH and if not set then relative path to the Mapfile or absolute path
>>        CLASS # define an empty CLASS here
>>        END
>>      END
>>
>> It will make it easier to export Mapfiles from other application such as QGIS, and to share styles e.g. between MapServer and GeoServer. More details are in the RFC.
>> Feedback and comments appreciated.
>>
>> I'll start with my +1,
>>
>> Seth
>>
>> --
>> web:https://geographika.net & https://mapserverstudio.net
>> twitter: @geographika
>> _______________________________________________
>> MapServer-dev mailing list
>> MapServer-dev at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/mapserver-dev
>
> -- 
> http://www.spatialys.com
> My software is free, but my time generally not.


More information about the MapServer-dev mailing list