I've a PostGIS table published as a layer, I need to style this layer using SLD. I need to call a custom OWS function (which I wrote) from inside the SLD. It should look something like:

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
  xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd"
  xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

      <Title>dark yellow square point style</Title>
          <Title>dark yellow point</Title>
                  <CssParameter name="fill">#99cc00</CssParameter>
              <ogc:Function name="gs:calcSize">
                <ogc:Function name="parameter">
                    <!-- **** What should I write here? **** -->


calcSize is a function to calculate point size depending on some calculations on the feature's fields.

My question is what should I write as a parameter of this function, actually I need to path the current feature as a parameter, so what should I write in the SLD as a parameter?

Also in the java side, what should the parameter type be?

1 Answer 1


In the SLD you need to name the properties being passed into the function as is shown in this example.

In the function itself you need to specify the parameter types you expect and then you receive a list of Parameters that it is up to your code to extract and check. See the function tutorial for more detail.

public class SnapFunction implements Function {

    static FunctionName NAME = new FunctionNameImpl("snap", Point.class,

    private final List<Expression> parameters;

    private final Literal fallback;

    public SnapFunction(List<Expression> parameters, Literal fallback) {
        if (parameters == null) {
            throw new NullPointerException("parameters required");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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