Follow the arrows
Here’s a neat trick for those working with road maps that want to indicate traffic direction by way of appropriately pointed arrows. With text symbolizers using font characters, this is actually a snap, provided your data includes information about direction.
The New York City streets data set has an attribute field called trafdir
which specifies the flow of traffic on one-way streets:
**W** - ("with") One-way in the direction of ascending street numbers **A** - ("against") One-way in the opposite direction of ascending street numbers
With this in mind, all that is needed is an SLD with two rules, each rule drawing an arrow pointing in appropriate direction specified by the trafdir
attribute. Since arrows are included in most fonts, this can be accomplished using text symbolizers. And since the text label is oriented relative to the lines themselves (due to labels that can follow curves) the arrows will automatically be properly aligned with the road.
Here is one of the SLD rules. The other rule is identical, except for the attribute value and the specific character used.
<Rule>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>trafdir</ogc:PropertyName>
<ogc:Literal>W</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<TextSymbolizer>
<Label>
<ogc:Literal>→</ogc:Literal>
</Label>
<Font>
<CssParameter name="font-family">Lucida Sans</CssParameter>
<CssParameter name="font-size">18</CssParameter>
</Font>
<Fill>
<CssParameter name="fill">#a4bdc5</CssParameter>
</Fill>
</TextSymbolizer>
</Rule>
This trick was figured out by Jordan Anderson, author of Ride The City, who goes on to say:
_"Probably the most challenging thing was getting the correct balance between street name labels and arrow labels (which are on two different layers). I became intimately familiar with all the new labeling options and made use of spaceAround, maxDisplacement, and Repeat to get something close to the right balance."_
Looks pretty good to me. Thanks Jordan!
Vulnerability
- GeoServer 2.25.4 Release
- GeoServer 2.26.0 Release
- CVE-2024-36401 Remote Code Execution (RCE) vulnerability in evaluating property name expressions
- GeoServer 2.25.2 Release
- GeoServer 2.24.4 Release
- GeoServer 2.23.6 Release
- GeoServer 2.25.1 Release
- GeoServer 2.25.0 Release
- GeoServer 2.23.5 Release
- GeoServer 2.24.2 Release