2

I'm trying to create a dynamic heatmap using GeoServer 2.8.3, but when it comes to validating the colormap-part of my SLD i keep getting the same error:

line 66: cvc-datatype-valid.1.2.1: '${env('high',1)}' ist kein gültiger Wert für 'double'.
line 66: cvc-attribute.3: Wert '${env('high',1)}' des Attributs 'quantity' bei Element 'ColorMapEntry' hat keinen gültigen Typ 'double'.

My code looks as followed

<ColorMap type="ramp">
                <ColorMapEntry color="#FFFFFF" quantity="0" opacity="1.0"/>
                <ColorMapEntry color="#4444FF" quantity="0.3" opacity="1.0"/>
                <ColorMapEntry color="#FF0000" quantity="0.7" opacity="1.0"/>
                <ColorMapEntry color="#FFFF00" quantity="${env('high',1)}" opacity="1.0"/>
              </ColorMap>

While the first three entrys work just fine, the fourth is causing the error to appear. I am pretty confused since i took the code right from the documentation (http://docs.geoserver.org/2.8.x/en/user/styling/sld-reference/rastersymbolizer.html#cql-expressions). Since i want the colormap to be fully customizable by the getmap-method, i would like to make every colormap-entry (color aswell as quantity) dynamic using the env-function.

Putting in ('high',1.0) instead of ('high',1) wont work.

I also found another question regarding the same matter, but it didnt help either (How do I use env parameter variables in an SLD colormap?).

Did anyone experience something similar?

The dynamic quantitys do work, but once i apply the same to the colors, it won't display the map at all.

<ColorMap type="ramp">
                <ColorMapEntry color="${env('c1',#FFFFFF)}" quantity="${env('zero',0)}" opacity="1.0"/>
                <ColorMapEntry color="${env('c2',#4444FF)}" quantity="${env('low',0.3)}" opacity="1.0"/>
                <ColorMapEntry color="${env('c3',#FF0000)}" quantity="${env('med',0.7)}" opacity="1.0"/>
                <ColorMapEntry color="${env('c4',#FFFF00)}" quantity="${env('high',1)}" opacity="1.0"/>
              </ColorMap>

Do i have to do something special with the color-codes? I am not getting any error outputs for these.

2
  • 2
    Not validating does not mean not working. Did you try to use the style anyways? Commented Apr 7, 2016 at 7:54
  • Just tried it, and it works! Thank you very much, the error code irritaded me too much i guess Commented Apr 7, 2016 at 8:09

1 Answer 1

3

Update: I found the solution and got a working SLD now. It is important to put the color codes in single quotes for GeoServer to recognize them as strings:

<ColorMapEntry color="${env('c4','#FFFF00')}" quantity="${env('high',1)}" opacity="1.0"/>

Upon validating I am still getting error messages, the SLD does work nonetheless. When accessing the variables through getMap, it is important to substitute the # with %23 in order for everything to work:

...&env=c1:%23DF7401;c2:%23BCA9F5&...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.