0

I am trying to create a SLD in GeoServer to change the layer style based on the attribute passed. I am using GoeServer Variable substitution. The following is block of my SLD.

<Rule>
<Name>Name</Name>
<Title>Title</Title>
<ogc:Filter>
    <ogc:PropertyIsLessThan>
        <ogc:Function name="property">
            <ogc:Function name="env">
                <ogc:Literal>attribute</ogc:Literal>
                <ogc:Literal>default_attribute</ogc:Literal>
            </ogc:Function>
        </ogc:Function>
        <ogc:Literal>20000</ogc:Literal>
    </ogc:PropertyIsLessThan>
</ogc:Filter>
<PolygonSymbolizer>
    <Fill>
        <CssParameter name="fill">#edf8fb</CssParameter>
        <CssParameter name="fill-opacity">0.5</CssParameter>
    </Fill>
</PolygonSymbolizer>

For example if I am passing the string 'atr1' through environment variable like this.

...&env=attribute:atr1&...

I am getting the exception as follows

The requested Style can not be used with this layer. The style specifies an attribute of [[atr1]] and the layer is: workspace:layer_name

Two square brackets gets added to the string which I passed. If I didn't pass any value for variable, the layer is getting displayed using default attribute. How to avoid those square brackets ?

I am using GeoServer version is 2.10.1

7
  • What version of GeoServer is that? May 24, 2018 at 12:28
  • what happens if you leave out <ogc:Function name="property">
    – Ian Turton
    May 24, 2018 at 12:28
  • @AndreaAime GeoServer version is 2.10.1
    – S. Thiyaku
    May 24, 2018 at 12:58
  • @IanTurton If I leave out <ogc:Function name="property">, Filter is not applied but whole layer is displayed.
    – S. Thiyaku
    May 24, 2018 at 13:08
  • 2.10.1 is old and unsupported, try 2.13.1, the issue might have been already solved in the meantime. May 25, 2018 at 10:04

0

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.