GeoServer – Using Environment Parameter Variables in an SLD Colormap

colormapgeoserversldwms

We have data being represented by the colormap copied below. I need to use env variables to change the hard coded color steps into whatever's input to the url parameters. I know you can use<ogc:Function name="env"> to pull variable values out of the url but I'm not really sure how to use that to replace the hard coded values. The colors aren't changing, just the quantity values. The getMap url would have something like &env=step1:1.0;step2:1.5; etc…

  <RasterSymbolizer>
    <Opacity>1</Opacity>
    <ColorMap type="ramp" extended="true">      
      <ColorMapEntry color="#000000" quantity="0" opacity="0" />
      <ColorMapEntry color="#0000FF" quantity="0.75" opacity="1" />
      <ColorMapEntry color="#00FF00" quantity="1.25" opacity="1" />
      <ColorMapEntry color="#FFFF00" quantity="1.75" opacity="1" />
      <ColorMapEntry color="#FF6600" quantity="2.25" opacity="1" />              
      <ColorMapEntry color="#FF0000" quantity="3.00" opacity="1" />              
    </ColorMap>
  </RasterSymbolizer>

I tried doing what http://docs.geoserver.org/latest/en/user/styling/sld-reference/rastersymbolizer.html suggested by using

<ColorMapEntry color="#0000FF" quantity="${env('step1',1)}"/>

but that didn't work. Geoserver throws

IllegalArgumentexception: Argument "quantityString" should not be null.

Which makes sense.

So the CQL expression didn't seem to work as I hoped. How do I get that to work or use the ogc function?

Using Geoserver 2.7.

Best Answer

It's been added since 2.7.1.

See release note here. Here the JIRA report.

Simone.

Related Question