0

The new wms_layer_group layer metadata tag appears to be inconsistent with legends.

  1. wms_layer_group cannot be combined with GROUP (re: this)
  2. GetLegendGraphic only works on CLASS items that have a defined name and group

Am I missing something?

Edit

If wms_layer_group and GROUP are used in the same map layer, nothing is rendered and an error is thrown by mapserver:

msWMSPrepareNestedGroups(): WMS server error. It is not allowed to set both the GROUP and WMS_LAYER_GROUP for a layer [Thu Nov 15 21:55:56 2018].751618 msDrawMap(): rendering using outputformat named png (AGG/PNG).

I have made some progress.

I thought that to have 2 legends and 2 styles I needed to use GROUP. Not true.

Turns out that CLASSGROUP, not GROUP, is what I needed. But it's not clear I need it.

What I think I know:

  1. In order to to make legends appear, you have to define a NAME for each class you want in the legend.
  2. If you want to have more than 1 'style' for layer (group of classes), you need to define a GROUP for each named CLASS.

Say I have 2 sets of classes for a single layer:

LAYER
  METADATA
    wms_layer_group "/Terrain/2 min resolution"
  END
  INCLUDE "terrain_light.style"
  INCLUDE "terrain_gray.style"
END

Both of these styles are nearly identical: same expression and pixel values / ranges. Only the colors applied to the values is different.

This all works:

  • I have a layer with 2 styles
  • Only 1 legend appears in 'GetLegendGraphic' requests
  • Either style can be requested

I still don't really understand class group in this case. The docs say you need it, but the rendering is the same regardless: The first group encountered is the 'default' style. If I group all the classes as indicated above, then the CLASSGROUP can be deleted with no ill effects.

I have not figured out how to declare a 'default' style, other than ensuring it is listed first in the mapfile. I thought CLASSGROUP might do this, but:

CLASSGROUP "Terrain (light)"
INCLUDE "terrain_gray.style"
INCLUDE "terrain_light.style"

Renders grayscale by default.

I'm still not convinced there isn't a more 'idiomatic' way to achieve these goals.

  • I'm not sure I understand the question. Legends show colours assigned to features, and that is done in the CLASS directive in a MapServer map file. Groups deal with bundling up sets of layers and have nothing to do assigning colours; that has always been the case. Could you put more detail in the question, with illustrative examples of what was possible before and not now. – nmtoken Nov 10 '18 at 9:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.