[Geoserver-users] Strange behaviour with variable substitution in SLD

Hi list,
I noticed something strange when using variable substitution in SLD.

I verified this, with geoserver 2.3.1 and 2.5

I have a postgis layer with point and a a numeric attribute.

THE LAYER
the_geom: Point
thevalue: BigDecimal

I have created a SLD with an ogc:filter

<?xml version="1.0" encoding="ISO-8859-1"?>

<StyledLayerDescriptor (…)>




ogc:Filter
ogc:PropertyIsLessThan
ogc:PropertyNamethevalue</ogc:PropertyName>
<ogc:Function name=“env”>
ogc:Literalthevalue</ogc:Literal>
ogc:Literal0</ogc:Literal>
</ogc:Function>
</ogc:PropertyIsLessThan>
</ogc:Filter>



circle

#FF0000


6






Making a GetMap request with the extra param &env=thevalue:50 I get this error:

Caused by: org.postgresql.util.PSQLException: ERROR: invalid input syntax for type numeric: “[50]”

In the output I found also this:

10 Apr 11:24:42 DEBUG [geotools.filter] - exporting LogicFilter
10 Apr 11:24:42 DEBUG [geotools.filter] - exporting PropertyName
10 Apr 11:24:42 DEBUG [geotools.filter] - exporting LiteralExpression
10 Apr 11:24:42 DEBUG [geotools.filter] - exporting SQL ComparisonFilter
10 Apr 11:24:42 DEBUG [geotools.filter] - exporting PropertyName
10 Apr 11:24:42 DEBUG [geotools.filter] - exporting LiteralExpression
10 Apr 11:24:42 DEBUG [geotools.filter] - exporting PropertyName
10 Apr 11:24:42 DEBUG [geotools.jdbc] - SELECT (…) WHERE (…) AND “thevalue” <= ‘[50]’ AND “thevalue” IS NOT NULL )
10 Apr 11:24:42 DEBUG [geotools.jdbc] - CLOSE CONNECTION
10 Apr 11:24:42 ERROR [geotools.rendering] - java.io.IOException
java.lang.RuntimeException: java.io.IOException
at org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:168)

As a workaround I changed the SLD like this:

<?xml version="1.0" encoding="ISO-8859-1"?>

<StyledLayerDescriptor (…)>







circle

0


0


thevalue thevalue 0 circle #FF0000 6

In this way request with or without the extra param works.
The same behavior happens if each OGC:Rule has an ogc:Filter.

Am I doing SLD styling wrong? Or this is not the GeoServer’s intended behavior?

Best regards

  • Milan