I have activated the mbstyle
plugin for GeoServer. This is part of a mbstyle, it contains a filter:
"filter": ["all", [">=", "scalerank", ["zoom"]]],
Which means I want to render only those features whose scalerank
is >=
the current zoom level.
And I found a sld file named the same as the mbstyle in the $geoserver_data_dir/styles/xxx.sld
, this should be generated by geoserver, and the above filer is transformed as this:
<ogc:Filter>
<ogc:And>
<ogc:PropertyIsGreaterThanOrEqualTo>
<ogc:PropertyName>scalerank</ogc:PropertyName>
<ogc:Literal>zoomLevel([env([wms_scale_denominator])], [EPSG:3857])</ogc:Literal>
</ogc:PropertyIsGreaterThanOrEqualTo>
</ogc:And>
</ogc:Filter>
When I preview the layer, I got the following error:
java.sql.SQLException: org.postgresql.util.PSQLException: ERROR: invalid input syntax for integer: "zoomLevel([env([wms_scale_denominator])], [EPSG:3857])"
How can I fix this?
Update for answer by @Andrea Aime:
I found the class ZoomLevelFunction extends FunctionExpressionImpl
which provide the zoomLevel
function, so the transformation in the sld is right/expected. But Geoserver pass this expression to database for features querying directly instead of evaluating it using the function. So is it the problem of geoserver or mbstyle?
Also follow this PR mentioned by @Andrea Aime, I change my filter to :
"filter": ["all", [">=", ["get","scalerank"], ["zoom"]]],
And the sld changed to:
<ogc:Filter>
<ogc:And>
<ogc:PropertyIsGreaterThanOrEqualTo>
<ogc:PropertyName>property([scalerank])</ogc:PropertyName>
<ogc:Literal>zoomLevel([env([wms_scale_denominator])], [EPSG:3857])</ogc:Literal>
</ogc:PropertyIsGreaterThanOrEqualTo>
</ogc:And>
</ogc:Filter>
But I got error:
This style specifies an attribute name property([scalerank]),not found in the xxx layer`.