[GIS] How to show street direction on map

directionsharpmapstreetsstylesymbology

I am using sharpmap to render my OPEN STREET MAPS (osm) maps. i need to show the direction of one way streets on my map.
How can i do that?!
After googling i found SharpMap.Rendering.Symbolizer and style.Line.DashPattern might help but i couldn't figure it how do it…!
i have the oneway column in my data, and i can filter my data for one way streets for styling, but i don't know how to style and draw a small arrow on my lines.

i want the arrows like this picture Street Directions

Best Answer

OK, after a few days researching finally i solved my own question, and i'm going to share it for others! First of all, sharpmap doesn't have a built in functionality to show the direction of streets, so we have to style the roads! for drawing a small arrow on the roads you should use LineSymbolizer of vactor Style. below is the code i have written to do this:

        VectorStyle style = new VectorStyle();
        var cls = new SharpMap.Rendering.Symbolizer.CachedLineSymbolizer();
        //styling the road
        cls.LineSymbolizeHandlers.Add(new SharpMap.Rendering.Symbolizer.PlainLineSymbolizeHandler { Line = new System.Drawing.Pen(Color.Gold, 3) });
        //drawing the arrow
        var wls = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander
        {
            Pattern = getArrowedLine(),
            Line = new System.Drawing.Pen(System.Drawing.Color.Gray, 2),
            Interval = 70
        };

        cls.LineSymbolizeHandlers.Add(wls);
        cls.ImmediateMode = true;
        style.LineSymbolizer = cls;

and the getArrowdLine function:

 private GraphicsPath getArrowedLine()
    {
        //creating the Arrow graphics like this ->
        var gp = new GraphicsPath();
        gp.AddLine(5, 2, 7, 0); //     \
        gp.AddLine(0, 0, 7, 0); // -----
        gp.AddLine(5, -2, 7, 0);//     /
        //if you dont close the figure you will have continuesly arrows like this ->->->->->
        //but if you close it, depend on interval you will have ->   ->   ->
        gp.CloseFigure();
        return gp;
    }

I am surprised why sharpmap did not implement ArrowedLine (which is commonly used in maps) in their WarpedLineSymbolizer class!!!

Related Question