GeoServer – Rotation in GeoServer SLD Guide

geoserversld

I am using the style editor in GeoServer to make some symbols for an OpenLayers based Web GIS solution. But I face a challenge when trying to rotate some symbols. I have a Point Layer that needs to be rotated based on the values in a field named "ROTATION".

This is fairly simple and I created the following SLD that do this:

enter image description here

But unfortunately the values in the rotation field is not providing the correct rotation (it might be radians or something)… so I get the following result in my Web GIS (it is the small black lines):

enter image description here

I wish the black lines to be perpendicular to the red and blue lines. I have calculated that I will get the right rotation using the formula:
(360 - "ROTATION" + 90) / 360

At least it works when I calculate a new field on the feature class using MSSQL (where the layer is currently stored). Unfortunately I can't do the trick in MSSQL as the data are currently in production.
So my question is – how do I get this formula to work on the field ROTATION in the SLD editor.

I am using GeoServer 2.10.

I have so far read that I might need something with "ogc:Literal"Formula"/ogc:Literal", but what should I write exactly.

Best Answer

Something like this should work, using the math operators - please note it is untested:

<Rotation>
    <ogc:Div>
        <ogc:Sub>
            <ogc:Literal>450</ogc:Literal>
            <ogc:PropertyName>ROTATION</ogc:PropertyName>
        </ogc:Sub>
        <ogc:Literal>360</ogc:Literal>
    </ogc:Div>
</Rotation>
Related Question