2

Am using geotools to render a set of point features. I have SLD for styling point features. The SLD uses an expression to calculate Rotation value based on Angle attribute value of feature. The features that have Angle value NULL are not rendered. I would like to specify default angle value of 0 when Angle attribute value is NULL.

Here is part of current SLD:

<sld:Rule>
<sld:Name>rule1</sld:Name>
<sld:PointSymbolizer>
<sld:Graphic>
<sld:ExternalGraphic>
<sld:OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="mysymbol.svg" xlink:type="simple"/>
<sld:Format>image/svg</sld:Format>
</sld:ExternalGraphic>
<sld:Opacity>
<ogc:Literal>1.0</ogc:Literal>
</sld:Opacity>
<sld:Size>
<ogc:Literal>11.0</ogc:Literal>
</sld:Size>
<sld:Rotation>
<ogc:Sub>
<ogc:Literal>360.0</ogc:Literal>
<ogc:PropertyName>Angle</ogc:PropertyName>
</ogc:Sub>
</sld:Rotation>
</sld:Graphic>
</sld:PointSymbolizer>
</sld:Rule>
2

You need to check if the value of rotation is null using a function: First you need an if_then_else function to select the outputs based on the isNull function's result. If the property is null it returns true and the if_then_else returns the first argument (the literal), if it is not null then it returns false and the second argument of the if is used (the sub).

<sld:Rotation>
   <ogc:Function name="if_then_else">
      <ogc:Function name="isNull">
         <ogc:PropertyName>Angle</ogc:PropertyName>
      </ogc:Function>
   <ogc:Literal>180</ogc:Literal>
   <ogc:Sub>
      <ogc:Literal>360.0</ogc:Literal>
      <ogc:PropertyName>Angle</ogc:PropertyName>
   </ogc:Sub>
   </ogc:Function>
</sld:Rotation>

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.