Arrow Sign on LineString

Topics: General Topics
Nov 1, 2010 at 9:34 AM

Hi,

I am add a layer with joining multiple point.

I want to show the Arrow direction with ENDCAP property, but no arrow display.

How to do it...

Another thing, if i want to display arrow after some interval, like ----->--->------->----, i it possible?? if yes how?

Sandip

 

Coordinator
Nov 1, 2010 at 6:58 PM

Hello sandipchk,

If you use NetTopologySuite you can use LocationIndexedLine class for disaggregate the LineString to a set of equally length LineStrings, each having an EndCap style to Arrow.

Please show us your style definition so we can see where it goes wrong.

Hth FObermaier

Nov 2, 2010 at 9:58 AM

Hi,

Can u send a example of  LocationIndexedLine

regards

Sandip.

Coordinator
Nov 2, 2010 at 12:31 PM

Sorry, should have been LengthIndexedLine:

public SharpMap.Geometries.MultiLineString SplitLineString(
    SharpMap.Geometries.LineString lineString, 
    System.Double length)
{
    if (lineString == null || lineString.IsEmpty())
        throw new System.ArgumentException("Linestring is null or Empty", "lineString");

    var gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory();
    var ntsLine = (GisSharpBlog.NetTopologySuite.Geometries.LineString)
                    SharpMap.Converters.NTS.GeometryConverter.ToNTSGeometry(lineString, gf);

    var ret = new SharpMap.Geometries.MultiLineString();
    var lil = new GisSharpBlog.NetTopologySuite.LinearReferencing.LengthIndexedLine(ntsLine);

    double currentLength = 0d;
    while (currentLength  < ntsLine.Length)
    {
        var tmpLine = (GisSharpBlog.NetTopologySuite.Geometries.LineString)
            lil.ExtractLine(currentLength, currentLength + length);
        ret.LineStrings.Add((SharpMap.Geometries.LineString)
            SharpMap.Converters.NTS.GeometryConverter.ToSharpMapGeometry(tmpLine));
        currentLength += length;
    }
    return ret;
}

Hth FObermaier

Nov 9, 2010 at 9:00 AM

Hi,

Thanks for your reply, I am using yor Code but not draw discontinued line with Arrow sign. my code givin bellow, please help

//   My Code

DataSet dSet = Library.Getdata(strSql, "VehicleRegistrationMaster");
List<SharpMap.Geometries.Point> pointList = new List<SharpMap.Geometries.Point>();

DataTable dTable = dSet.Tables[0];
foreach (DataRow dRow in dTable.Rows)
{
   
    double lng = System.Convert.ToDouble(dRow["long"]);
    double lat = System.Convert.ToDouble(dRow["lat"]);

    SharpMap.Geometries.Point p1 = new SharpMap.Geometries.Point(lng, lat);
    pointList.Add(p1);
   
    FeatureDataRow fdr = fdt.NewRow();
    fdr.Geometry = new SharpMap.Geometries.Point(lng, lat);
    fdt.AddRow(fdr);

}

SharpMap.Layers.VectorLayer layPOI = new SharpMap.Layers.VectorLayer("POI");
layPOI.DataSource = new GeometryFeatureProvider(fdt);
layPOI.Style.Fill = new System.Drawing.SolidBrush(Color.Violet);
layPOI.Style.Symbol = new System.Drawing.Bitmap(Server.MapPath(@"~\App_data\marker.gif"));


//Add Dynamic Line String if HISTORY
SharpMap.Layers.VectorLayer layLine = new SharpMap.Layers.VectorLayer("LINE");

FeatureDataTable fdl = new FeatureDataTable();
FeatureDataRow fdlr1 = fdl.NewRow();
fdlr1.Geometry = SplitLineString(new SharpMap.Geometries.LineString(pointList), 0.2);             
fdl.AddRow(fdlr1);

layLine.DataSource = new GeometryFeatureProvider(fdl);
layLine.Style.Fill = new System.Drawing.SolidBrush(Color.Green);
layLine.Style.Line = new Pen(Color.Green, 2F);
layLine.Style.Line.DashPattern = new float[] { 4.0f, 2.0f };
layLine.Style.Line.EndCap = System.Drawing.Drawing2D.LineCap.Triangle;

//

I want the line string like ---------->---------------->----------------->

Regards

Sandip Chakraborty

 

Coordinator
Nov 9, 2010 at 9:43 AM

Hello Sandip,

you would have to use System.Drawing.Drawing2D.LineCap.ArrowAncor. The LineCap styles in that enumeration scale with the pens width, therefore you might not see anything if you use slim pens.

As an alternative you could create your own cap style by creating a CustomLineCap and assign that to the pens CustomEndCap

Hth FObermaier