2

I'm using Geoserver 2.6.2. I need to represent direction arrows for line features. I have managed to position such marks on lines centroid but I need to position these arrows on the side of the lines. The perpendicularOffset option used for line labels would be the solution I'm looking for but it is restricted to labels styling. How would you code your SLD in order to achieve that?

Below is the code I'm using so far to position arrows on lines:

    <Rule>
      <Name>Lines</Name>
      <Title>Lines</Title>
      <LineSymbolizer>
        <Stroke>
          <CssParameter name="stroke">#000000</CssParameter>
          <CssParameter name="stroke-width">1</CssParameter>
        </Stroke>
      </LineSymbolizer>
      <PointSymbolizer>
        <Geometry>
          <ogc:Function name="centroid">
            <ogc:PropertyName>the_geom</ogc:PropertyName>
          </ogc:Function>
        </Geometry>
        <Graphic>
          <Mark>
            <WellKnownName>shape://oarrow</WellKnownName>
            <Fill>
              <CssParameter name="fill-opacity">0</CssParameter>
            </Fill>
            <Stroke>
              <CssParameter name="stroke-width">1</CssParameter>
            </Stroke>
          </Mark>
          <Size>20</Size>
          <Rotation>
            <ogc:Function name="endAngle">
              <ogc:PropertyName>the_geom</ogc:PropertyName>
            </ogc:Function>
          </Rotation>
        </Graphic>
      </PointSymbolizer>        
    </Rule>
2

As far as I know there isn't an existing function to do that, it might be possible to use the offset function to move an arrow but you'd need to know which direction to go in.

GeoServer does have startPoint and startAngle (and matching end...) functions to allow you to put arrows at the beginning and end of lines.

If You must label the centre of the line then you will need to write a new function (based on endAngle and offset) and add it to your GeoServer.

  • Thank you @iant. I wanted to make sure I wasn't missing an existing function... Writing my own function would be too difficult for me. – wiltomap Jan 18 '16 at 9:18

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.