[Geoserver-users] filter

Hello community!

I’ve got troubles with filter expression. I have an integer column with values, like 2, 5, 30, 100…
And I need to filter those divisible by 25, for instance.

Since I’m currently unable to manipulate the DB (to create the views for I need) the only option is sld-filtering. Is there any way to achieve this?


Regards,
Yaras

You’ll want the IEEERemainder function documented on the Filter Function Reference page (https://docs.geoserver.org/latest/en/user/filter/function_reference.html#math-functions) -

      <ogc:Filter>
        <ogc:PropertyIsEqualTo>
          <ogc:Function name="IEEERemainder">
            <ogc:Function name="int2ddouble">
              <ogc:PropertyName>propertyVa</ogc:PropertyName>
            </ogc:Function>
            <ogc:Literal>20.0</ogc:Literal>
          </ogc:Function>
          <ogc:Literal>0</ogc:Literal>
        </ogc:PropertyIsEqualTo>
      </ogc:Filter> 

Ian

···

Ian Turton

Thanks for the tip, Ian!

In GS v.2.20.4 I see the following error: «Filter function problem for function int2ddouble argument #0 — expected type int»

Changed a bit to this:

ogc:Filter
ogc:PropertyIsEqualTo
<ogc:Function name=“IEEERemainder”>
ogc:PropertyNamepropertyVa</ogc:PropertyName>
ogc:Literal20.0</ogc:Literal>
</ogc:Function>
ogc:Literal0</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>

And it worked!