Is it possible to use math in SLD file in Geotools? I want to get Orientation for lines and calculate its sine/cosine and then multiply it with some value. But when I do this nothing shows up. Here is part polygon symbolizer that I am using.

    <ogc:Function name="buffer">
                    33 )</WellKnownName>
                    <CssParameter name="stroke">#000000</CssParameter>
                    <CssParameter name="stroke-width">1</CssParameter>

Function for multiplication is


for sine I am not sure what function is, but it doesn't work when only multiplication is used. This is needed because when adding hatches to objects, there is need to draw a hatch with angle of 45 to one side of object. Something like this, but when object is rotated by some angle.


1 Answer 1


You can do math in SLD in most places, but a WellKnownMark element is not one of them.

This is what the standard says, GeoServer has a custom extension allowing to stick a CQL expression in the middle of a mark name like this:

wkt://LINESTRING(0 0, ${Orientation * 200} 33)

I could not try it out, but it should work.

  • It works, solution that I am now using to achieve this is wkt://LINESTRING(0 0, ${sin(Orientation) * 200} ${cos(Orientation) * 200}) If somebody need it Mar 4, 2017 at 15:48

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.