2

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`.

1 Answer 1

1

The MBStyle module for the moment supports only the old expression syntax, but not the current one. There is work ongoing to improve that: https://github.com/geotools/geotools/pull/2930

5
  • Is it expected to transform zoom to zoomLevel([env([wms_scale_denominator])]?
    – giser
    May 30, 2020 at 20:31
  • It is, there is no such a thing as "zoom" in the OGC rendering machinery, only scale denominators. That function turns the current scale denominator into the closest zoom level in the web mercator gridset assumed by MBStyle. May 31, 2020 at 17:04
  • Hi, can you check my update?
    – giser
    Jun 1, 2020 at 0:54
  • That's a PR, that is, work in progress not yet available to end users. Jun 1, 2020 at 7:34
  • Ok, thank you very much.
    – giser
    Jun 1, 2020 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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