CreateLineString Issue

Oct 14, 2015 at 5:17 PM
Hello

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.

TEXT

Please help me what is causing issue in drawing line.
  • LV
Oct 14, 2015 at 5: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.
Coordinator
Oct 15, 2015 at 8:55 AM
Could you post the code you use to create the linestrings?
Oct 15, 2015 at 1:44 PM
Fobermaier,

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);
                            geomColl.Add(factory.CreatePoint(locations[0]));
                            geomColl.Add(factory.CreatePoint(locations[1]));
                            geomColl.Add(factory.CreateLineString(locations.ToArray()));


                            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();
                            _map.Layers.Add(gl);
Coordinator
Oct 16, 2015 at 7:59 AM
Edited Oct 16, 2015 at 7: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 6:44 PM
FObermaier,

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.