This project has moved and is read-only. For the latest updates, please go here.

CreateLineString Issue

Oct 14, 2015 at 6:17 PM

We are using sharpmap in our project and we need to add line for two points on map. We had no issues drawing line like "\" If we draw a line like "/" line is shifting from / to .

Please find image at below location.


Please help me what is causing issue in drawing line.
  • LV
Oct 14, 2015 at 6:21 PM
Adding comments for Image at above thread location.

When i draw line from Dallas to Houston it was showing fine. if i draw line from san antonio to dallas it was shifted as shown in image.
Oct 15, 2015 at 9:55 AM
Could you post the code you use to create the linestrings?
Oct 15, 2015 at 2:44 PM

Please find the code as below.

var locations = new List<GeoAPI.Geometries.Coordinate>();
                            locations.Add(new GeoAPI.Geometries.Coordinate(stLong,stLat));
                            locations.Add(new GeoAPI.Geometries.Coordinate(endLong,endLat));

                            //var lineGeometry = new NetTopologySuite.Geometries.LineString(locations.ToArray());

                            Collection<GeoAPI.Geometries.IGeometry> geomColl = new Collection<GeoAPI.Geometries.IGeometry>();
                            var factory = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory(4326);

                            var name = "Distance--" + stLat + stLong;
                            var gl = new SharpMap.Layers.VectorLayer(name);
                            gl.DataSource = new SharpMap.Data.Providers.GeometryProvider(geomColl);

                            gl.Style.Outline = new Pen(Color.Red);
                            gl.Style.Fill = Brushes.Transparent;// Outline = new Pen(Color.Black); ;
                          //  gl.Style.PointColor = Brushes.Red;
                            gl.Style.Outline = new Pen(Color.Black, 1);
                            gl.Style.Line = new Pen(Color.Red, 2);
                            gl.Style.Line.StartCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;
                            gl.Style.Line.EndCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;
                            gl.Style.Line.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;

                            gl.Style.EnableOutline = true;
                            gl.SRID = 4326;
                            gl.SmoothingMode = SmoothingMode.AntiAlias;
                            gl.CoordinateTransformation = ProjHelper.LatLonToGoogle();
Oct 16, 2015 at 8:59 AM
Edited Oct 16, 2015 at 8:59 AM
Where do stLong, stLat, endLong and endLat come from? I assume there is sth wrong with the computation of these values.
Oct 27, 2015 at 7:44 PM

Sorry for the delay in responding. After careful debugging through code found the miscalculation in lat/longs that are being sent stLong,stLat,endLong,endLat.

Issue is resolved after correcting lat/longs.

Thanks for quick response.