1

I have a shapefile that I have stored in GeoServer. I have some SVG symbols that I want to use for each point. I want the SVG symbols to rotate based on the orientation column (attribute value) in the shapefile plus 90 degrees.

I found that

<Rotation> 
    <ogc:PropertyName>rotation_column</ogc:PropertyName>
</Rotation>

will rotate the symbol by "rotation_column".

I also found that

<Rotation> 
   <ogc:Literal>90</ogc:Literal>
</Rotation>

will rotate 90 degrees.

I want to rotate "rotation_column" + 90 degrees. How can I do it?

This is my whole SLD after applying @Andrea Aime 's suggestion:



<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<StyledLayerDescriptor version="1.1.0" xsi:schemaLocation="http://www.opengis.net/sld 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" xmlns:se="http://www.opengis.net/se">
  <NamedLayer>
    <se:Name>CallingInPoint</se:Name>
    <UserStyle>
      <se:Name>CallingInPoint</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>CallingInPoint (L) - trafficFlow = 1</se:Name>
          <ogc:Filter xmlns="http://www.opengis.net/ogc">
              <PropertyIsEqualTo>
                <PropertyName>trafficFlo</PropertyName>
                <Literal>inbound</Literal>
              </PropertyIsEqualTo>
          </ogc:Filter>
          <se:PointSymbolizer uom="http://www.opengeospatial.org/se/units/pixel">
            <se:Graphic>
              <se:ExternalGraphic>
                <se:OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="RadioCallingInPoint_2.svg"/>
                <se:Format>image/svg+xml</se:Format>
              </se:ExternalGraphic>
              <se:Size>18</se:Size>
                
                <Rotation> 
                    <ogc:Add>
                        <ogc:PropertyName>orientatio</ogc:PropertyName>
                        <ogc:Literal>90</ogc:Literal>
                    </ogc:Add>
                </Rotation>


              
            </se:Graphic>
          </se:PointSymbolizer>
            <se:LineSymbolizer>
                <se:Stroke>
                    <se:SvgParameter name="stroke">#C045D1</se:SvgParameter>
                    <se:SvgParameter name="stroke-width">1</se:SvgParameter>
                    <se:SvgParameter name="stroke-dasharray">12 6</se:SvgParameter>
                </se:Stroke>                        
            </se:LineSymbolizer>
        </se:Rule>
        <se:Rule>
          <se:Name>CallingInPoint (L) - trafficFlow = 2</se:Name>
              <ogc:Filter xmlns="http://www.opengis.net/ogc">
                  <PropertyIsEqualTo>
                    <PropertyName>trafficFlo</PropertyName>
                    <Literal>outbound</Literal>
                  </PropertyIsEqualTo>
              </ogc:Filter>
          <se:PointSymbolizer uom="http://www.opengeospatial.org/se/units/pixel">
            <se:Graphic>
              <se:ExternalGraphic>
                <se:OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="RadioCallingInPoint_3.svg"/>
                <se:Format>image/svg+xml</se:Format>
              </se:ExternalGraphic>
              <se:Size>18</se:Size>
                <Rotation> 
                    <ogc:Add>
                        <ogc:PropertyName>orientatio</ogc:PropertyName>
                        <ogc:Literal>90</ogc:Literal>
                    </ogc:Add>
                </Rotation>
            </se:Graphic>
          </se:PointSymbolizer>
            <se:LineSymbolizer>
                <se:Stroke>
                    <se:SvgParameter name="stroke">#C045D1</se:SvgParameter>
                    <se:SvgParameter name="stroke-width">1</se:SvgParameter>
                    <se:SvgParameter name="stroke-dasharray">12 6</se:SvgParameter>
                </se:Stroke>                        
            </se:LineSymbolizer>
        </se:Rule>
        <se:Rule>
          <se:Name>CallingInPoint (L) - trafficFlow = 3</se:Name>
          <ogc:Filter xmlns="http://www.opengis.net/ogc">
              <PropertyIsEqualTo>
                <PropertyName>trafficFlo</PropertyName>
                <Literal>one-way</Literal>
              </PropertyIsEqualTo>
          </ogc:Filter>
          <se:PointSymbolizer uom="http://www.opengeospatial.org/se/units/pixel">
            <se:Graphic>
              <se:ExternalGraphic>
                <se:OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="RadioCallingInPoint_2.svg"/>
                <se:Format>image/svg+xml</se:Format>
              </se:ExternalGraphic>
              <se:Size>18</se:Size>
                <Rotation> 
                    <ogc:Add>
                        <ogc:PropertyName>orientatio</ogc:PropertyName>
                        <ogc:Literal>90</ogc:Literal>
                    </ogc:Add>
                </Rotation>
            </se:Graphic>
          </se:PointSymbolizer>
            <se:LineSymbolizer>
                <se:Stroke>
                    <se:SvgParameter name="stroke">#C045D1</se:SvgParameter>
                    <se:SvgParameter name="stroke-width">1</se:SvgParameter>
                    <se:SvgParameter name="stroke-dasharray">12 6</se:SvgParameter>
                </se:Stroke>                        
            </se:LineSymbolizer>
        </se:Rule>
         <se:Rule>
          <se:Name>CallingInPoint (L) - trafficFlow = 4</se:Name>
          <ogc:Filter xmlns="http://www.opengis.net/ogc">
              <PropertyIsEqualTo>
                <PropertyName>trafficFlo</PropertyName>
                <Literal>two-way</Literal>
              </PropertyIsEqualTo>
          </ogc:Filter>
          <se:PointSymbolizer uom="http://www.opengeospatial.org/se/units/pixel">
            <se:Graphic>
              <se:ExternalGraphic>
                <se:OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="RadioCallingInPoint_4.svg"/>
                <se:Format>image/svg+xml</se:Format>
              </se:ExternalGraphic>
              <se:Size>18</se:Size>
                <Rotation> 
                    <ogc:Add>
                        <ogc:PropertyName>orientatio</ogc:PropertyName>
                        <ogc:Literal>90</ogc:Literal>
                    </ogc:Add>
                </Rotation>   
            </se:Graphic>
          </se:PointSymbolizer>
            <se:LineSymbolizer>
                <se:Stroke>
                    <se:SvgParameter name="stroke">#C045D1</se:SvgParameter>
                    <se:SvgParameter name="stroke-width">1</se:SvgParameter>
                    <se:SvgParameter name="stroke-dasharray">12 6</se:SvgParameter>
                </se:Stroke>                        
            </se:LineSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>


"orientatio" is the column that I want to have the rotation based on it.

2 Answers 2

2

This should do the trick

<Rotation> 
    <ogc:Add>
      <ogc:PropertyName>rotation_column</ogc:PropertyName>
      <ogc:Literal>90</ogc:Literal>
    </ogc:Add>
</Rotation>
3
  • I applied it and now I have an error: line 24: cvc-complex-type.2.4.a: Invalid content was found starting with element 'Rotation'. One of '{"opengis.net/se":Rotation, "opengis.net/se":AnchorPoint, "opengis.net/se":Displacement}' is expected. My tags start with <se: ... > yours with <ogc: ...> can it be because of it? even what does that ogc and se mean here?
    – milad
    Commented Dec 16, 2022 at 15:33
  • 1
    Ouch, you're using SLD 1.1 instead of SLD 1.0. Try adding the prefixes to rotation (<se:Rotation>), but my example was meant to be used with SLD 1.0 Commented Dec 16, 2022 at 16:07
  • 1
    The validation error you have now seems due to the order of the elements, the SLD schema dictates a specific order. Looks like you're working inside a PointPlacement? In any case, see the expected order here: schemas.opengis.net/se/1.1.0/Symbolizer.xsd Commented Dec 17, 2022 at 16:37
0

The answer that @Andrea Aime has suggested is correct. In order to fix the error, I added se: before Rotation tag, But I would appreciate if someone can explain what se: means.

<se:Rotation> 
    <ogc:Add>
      <ogc:PropertyName>rotation_column</ogc:PropertyName>
      <ogc:Literal>90</ogc:Literal>
    </ogc:Add>
</se:Rotation>
1
  • 1
    It's a prefix commonly used for the http://www.opengis.net/se namespace, of the "Symbology Encoding" specification, upon which the SLD 1.1 schema is built. Commented Dec 17, 2022 at 16:38

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.