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!
- FOSS4G 2018 GeoServer Developers Workshop
- GeoServer at FOSS4G 2017 Boston
- REST API Code Sprint Prep
- Nov 18th Bug Stomp
- Online GeoServer Bug Stomp - July 2016 Results
- Online GeoServer Bug Stomp
- GeoServer Explorer Plugin for QGIS
- New repository and release delay
- GeoServer FOSS4G 2015 Activities
- GeoServer 2.4.0 Release Highlights