[MapServer-users] classgroup and group for styles

Seth G sethg at geographika.co.uk
Sun Jul 7 06:47:51 PDT 2024


Hi Jörg,

> 1st:
> naming the classgroup and the group-item within the classes "default" 
> the style does not appear in the capabilities. I think, if there are 
> more than one style, both/all styles have to be provided in the 
> capabilities.

The spec at https://www.ogc.org/standard/wms/ states:

"7.2.4.6.5 Style: Zero or more Styles may be advertised for a Layer or collection of layers using <Style> elements, each of which shall have <Name> and <Title> elements. The style's Name is used in the Map request STYLES parameter. The
Title is a human-readable string. If only a single style is available, that style is known as the “default” style and need not be advertised by the server."

Reading the above, I'd agree with you that if there are multiple styles available then the "default" should be listed. Maybe others know more about this part of the WMS spec?
Looking through the Mapserver codebase if the GROUP is named "default" then it won't be added to GetCapabilities in any scenario - unless the "default" name is changed using:

WEB
    METADATA
        wms_style_name "different-default-name"
    END
END   

See https://www.mapserver.org/ogc/inspire.html for more details on the METADATA settings. 

I ran into a side effect of this when using a GROUP "default" in a CLASS and a different CLASSITEM value for the layer. I could never select this style using STYLES=default in a querystring as it would use the CLASS GROUP specified in CLASSITEM. In summary, "default" should be seen as a reserved work for CLASS GROUP. 


> 2nd:
> You need to name the classes, otherwise the style-names are not provided.

There is a check in the codebase to ensure NAME is set, or it is ignored in the GetCapabilities. I think this is because the GetCapabilities needs to populate the LegendURL section for a GetLegendGraphic request. Without a NAME a CLASS isn't listed in a legend. 
I think this should be added to the docs at https://mapserver.org/mapfile/class.html#mapfile-class-name, or at least on the https://www.mapserver.org/ogc/wms_server.html page. 

Maybe this gets simpler with the OGC Maps API!

Seth

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

On Tue, Jul 2, 2024, at 5:28 PM, Jörg Thomsen (WhereGroup) via MapServer-users wrote:
> Hello,
>
> I've found an undocumented behavior of MapServer configuring different 
> layer-styles. My questions are:
>
> - Am I not able to find the documentation?
> - Is it a wanted or an unwanted behavior?
> - Am I wrong?
>
> 1st:
> naming the classgroup and the group-item within the classes "default" 
> the style does not appear in the capabilities. I think, if there are 
> more than one style, both/all styles have to be provided in the 
> capabilities.
>
> 2nd:
> You need to name the classes, otherwise the style-names are not provided.
>
> Jörg
>
> # only style 'red' is provided:
>
> https://schulung.foss.academy/cgi-bin/mapserv?map=styletest&SERVICE=WMS&REQUEST=GetCapabilities
>
>
>
> # style default:
>
> https://schulung.foss.academy/cgi-bin/mapserv?map=styletest&STYLES=default&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=32.82367387033398387%2C65.81237721021611264%2C40%2C76.31237721021611264&CRS=EPSG%3A4326&WIDTH=1018&HEIGHT=697&LAYERS=inline_stops&FORMAT=image%2Fpng&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi%3A96&TRANSPARENT=TRUE
>
>
>
> # style 'secret' (not in capabilities)
>
> https://schulung.foss.academy/cgi-bin/mapserv?map=styletest&STYLES=secret&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=32.82367387033398387%2C65.81237721021611264%2C40%2C76.31237721021611264&CRS=EPSG%3A4326&WIDTH=1018&HEIGHT=697&LAYERS=inline_stops&FORMAT=image%2Fpng&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi%3A96&TRANSPARENT=TRUE
>
>
>
> MAP
>
>      NAME "wms_freiburg_different_styles"
>
>      EXTENT 60 30 80 40
>
>      PROJECTION
>
>          "init=epsg:4326"
>
>      END
>
>
>
> 	WEB	
>
> 		METADATA
>
> 			WMS_TITLE    "test"
>
> 			WMS_ENABLE_REQUEST "*"
>
> 			WMS_SRS   "EPSG:4326"
>
> 		END
>
> 	END
>
>
>
>      Symbol
>
>        NAME "square"
>
>        Type ellipse
>
>          Points 1 1 END
>
>          Filled TRUE
>
>      END
>
>
>
> 	LAYER
>
> 	  NAME "inline_stops"
>
> 	  TYPE POINT
>
> 	  		METADATA
>
> 			WMS_TITLE    "test"
>
> 		END
>
> 	  FEATURE
>
> 		POINTS
>
> 		  69 35 71 37 72 38
>
> 		END
>
> 	  END
>
>	
>
> 	  CLASSGROUP 'default'
>
>	
>
> 	  CLASS
>
> 	    GROUP 'default'
>
> 		STYLE
>
> 		  COLOR 0 0 250
>
> 		  SYMBOL 'square'
>
> 		  SIZE 6
>
> 		END
>
> 	  END
>
>
>
> 	  CLASS
>
> 	    NAME 'red'
>
> 	    GROUP 'red'
>
> 		STYLE
>
> 		  COLOR 255 0 0
>
> 		  SYMBOL 'square'
>
> 		  SIZE 6
>
> 		END
>
> 	  END
>
>
>
> 	  CLASS
>
> 	    #NAME 'none'
>
> 	    GROUP 'secret'
>
> 		STYLE
>
> 		  COLOR 100 100 100
>
> 		  SYMBOL 'square'
>
> 		  SIZE 6
>
> 		END
>
> 	  END
>
>	
>
> 	END
>
> END
>
>
>
>
>
>
> -- 
> Viele Grüße,
> Jörg Thomsen
>
> ***********************************************************
> FOSS Academy Sommerschule: Kompaktkurs zum Aufbau einer GDI
> 02.-06. September 2024, Präsenzveranstaltung in Bonn
> https://www.foss-academy.com/kompaktkurse
> ***********************************************************
>
>
> Jörg Thomsen
> WhereGroup GmbH
> Bundesallee 23
> 10717 Berlin
> Germany
>
> Tel: +49 (0)30 / 5130 278 74
> Fax: +49 (0)30 / 5130 278 11	
>
> joerg.thomsen at wheregroup.com
> www.wheregroup.com
>
> Geschäftsführer:
> Olaf Knopp, Peter Stamm
> Amtsgericht Bonn, HRB 9885
>
> _______________________________________________
> MapServer-users mailing list
> MapServer-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/mapserver-users


More information about the MapServer-users mailing list