Following on from the post on Enhanced Stylization on the Geospatial Navigator blog, I would like to illustrate how to add flow direction to linestyles.
We'll start by adding a layer with enhanced stylization for a linestring feature class as shown in the Annotation Layers post.
Double-click the layer in the Display Manager and select the ellipse button (...) in the Feature Label column. In the Style and Label Editor dialog select the Feature Symbol Label tab. Add a symbol by clicking the green plus sign. This generates a default square symbol. Set the colors and sizes to your liking, and click OK and Apply, and exit the style editor. Save the layer by right-clicking the layer in the Display Manager and choosing Save Layer....
Edit the layer file with your favorite text editor (one that understands XML if possible) and find the SymbolInstance for the square.
<SymbolInstance>
<SimpleSymbolDefinition>
<Name>Square</Name>
<Description>Default Point Symbol</Description>
<Graphics>
<Path>
<Geometry>M -1.0,-1.0 L 1.0,-1.0 L 1.0,1.0 L -1.0,1.0 L -1.0,-1.0</Geometry>
<FillColor>%FILLCOLOR%</FillColor>
<LineColor>%LINECOLOR%</LineColor>
<LineWeight>%LINEWEIGHT%</LineWeight>
</Path>
</Graphics>
<LineUsage>
<AngleControl>FromAngle</AngleControl>
<Angle>%ROTATION%</Angle>
<Repeat>1.0</Repeat>
</LineUsage>
The geometry encoding is described in various documents on Advanced Stylization available at the OsGeo site, but it's pretty simple. For the default square symbol, this is M -1.0,-1.0 L 1.0,-1.0 L 1.0,1.0 L -1.0,1.0 L -1.0,-1.0. The interpretation of this sequence is shown in the figure. Basically it says Move to the lower left corner, then draw Lines around a square in the Cartesian plane.
Replace the Geometry contents with an arrow shape such as,
M -1.0,-1.0 L -1.0,1.0 L 1.0,0.0 L -1.0,-1.0. This says Move to the lower left corner and draw Lines in a triangle shape with the point to the right. The last L -1.0,-1.0 could be replaced by Z which draws a closing line to the starting point. If you change the size of the symbol, another element to play with is the Repeat interval which indicates how often the symbol should be repeated along the line.
Change the AngleControl to be FromGeometry instead of FromAngle, which makes the base angle for the rotation expression aligned with the geometry of the line instead of absolute zero degrees (east). You can optionally change all references to the name Square into something like Arrow and the description to something more appropriate, but this isn't required. Save the file.
Back in the Topobase Client, you can remove the original layer and drag your edited layer file onto the Display Manager. You should see the same stylization as before, but the squares will now be your triangle symbols aligned with the linestrings they lie on.
Now for the magic. Return to the Feature Symbol Label tab of the
Style and Label Editor dialog. Cick the Expression button next to the Rotation parameter and enter an expression that evaluates to zero for forward flow linestrings and 180 for reverse direction flow. You can use If, Lookup or NullValue for example, which are found under the Conversion button. The general form of the IF expression is If ([condition], [trueValue], [falseValue]). In this example the condition is setup to compare the value of the UTILITY_INFO attribute to 1. If it is equal to 1 the true expression is used (180.0). Otherwise the false expression is used (0.0), see the screenshot. For your data model and flow attribute values, you will probably need a different expression.
As you can see, the triangles are normally aligned with the digitization direction of the linestring - zero degrees FromGeometry, but if the UTILITY_INFO attribute is set to 1, then the triangles are reversed - 180 degrees FromGeometry.
The symbol can be symbolized with color, line thickness, etc. or scaled unequally to get a pointier arrow, but if you want a two line arrow or a curved arrow head, you would need to change the geometry encoding to eliminate the line opposite the triangle tip or use curves instead of lines.
tried it. nice.
Posted by: frank bowne | January 04, 2010 at 12:03 PM