public void Multils() { Random rnd = new Random(); LineString[] ls = new LineString[40]; GeoAPI.Geometries.ILineString[] lscheck = new GeoAPI.Geometries.ILineString[40]; GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory(); for (int ii = 0; ii < 40; ii++) { Coordinate[] coord = new Coordinate[36]; GeoAPI.Geometries.ICoordinate[] coordcheck = new GeoAPI.Geometries.ICoordinate[36]; for (int i = 0; i < 36; i++) { coord[i] = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); double x = coord[i].X; double y = coord[i].Y; GisSharpBlog.NetTopologySuite.Geometries.Coordinate c = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y); coordcheck[i] = c; } ls[ii] = new LineString(coord); lscheck[ii] = gf.CreateLineString(coordcheck); } MultiLineString mls = new MultiLineString(ls); GeoAPI.Geometries.IMultiLineString mlscheck = gf.CreateMultiLineString(lscheck); for (int ii = 0; ii < mls.Coordinates.Count; ii++) { Assert.AreEqual(mls.Coordinates[ii].X, mlscheck.Coordinates[ii].X); Assert.AreEqual(mls.Coordinates[ii].Y, mlscheck.Coordinates[ii].Y); } Assert.AreEqual(mls.NumGeometries, mlscheck.NumGeometries); }
public void Multils() { var rnd = new Random(); var ls = new LineString[40]; var lscheck = new GeoAPI.Geometries.ILineString[40]; var gf = new NetTopologySuite.Geometries.GeometryFactory(); for (var ii = 0; ii < 40; ii++) { var coord = new Coordinate[36]; var coordcheck = new GeoAPI.Geometries.Coordinate[36]; for (var i = 0; i < 36; i++) { coord[i] = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); var x = coord[i].X; var y = coord[i].Y; var c = new GeoAPI.Geometries.Coordinate(x, y); coordcheck[i] = c; } ls[ii] = new LineString(coord); lscheck[ii] = gf.CreateLineString(coordcheck); } var mls = new MultiLineString(ls); var mlscheck = gf.CreateMultiLineString(lscheck); for (var ii = 0; ii < mls.Coordinates.Count; ii++) { Assert.AreEqual(mls.Coordinates[ii].X, mlscheck.Coordinates[ii].X); Assert.AreEqual(mls.Coordinates[ii].Y, mlscheck.Coordinates[ii].Y); } Assert.AreEqual(mls.NumGeometries, mlscheck.NumGeometries); }
/// <summary> /// Method to place the street direction symbols /// </summary> /// <param name="map"></param> /// <param name="lineString"></param> /// <param name="graphics"></param> private void OnRenderInternal(SharpMap.MapViewport map, GeoAPI.Geometries.ILineString lineString, System.Drawing.Graphics graphics) { var length = lineString.Length; var lil = new NetTopologySuite.LinearReferencing.LengthIndexedLine(lineString); if (length < RepeatInterval + ArrowLength) { var start = System.Math.Max(0, (length - ArrowLength) / 2); var end = System.Math.Min(length, (length + ArrowLength) / 2); var arrow = (GeoAPI.Geometries.ILineString)lil.ExtractLine(start, end); RenderArrow(map, graphics, arrow); return; } var numArrows = (int)((lineString.Length - ArrowLength) / RepeatInterval); var offset = (lineString.Length - numArrows * RepeatInterval - ArrowLength) * 0.5; while (offset + ArrowLength < lineString.Length) { var arrow = (GeoAPI.Geometries.ILineString)lil.ExtractLine(offset, offset + ArrowLength); RenderArrow(map, graphics, arrow); offset += RepeatInterval; } }
public GeoAPI.Geometries.IMultiLineString SplitLineString( GeoAPI.Geometries.ILineString lineString, System.Double length) { if (lineString == null || lineString.IsEmpty) { throw new System.ArgumentException("Linestring is null or Empty", "lineString"); } //var gf = new NetTopologySuite.Geometries.GeometryFactory(); //var ntsLine = (NetTopologySuite.Geometries.LineString) // SharpMap.Converters.NTS.GeometryConverter.ToNTSGeometry(lineString, gf); var ret = new System.Collections.Generic.List <GeoAPI.Geometries.ILineString>(); var lil = new NetTopologySuite.LinearReferencing.LengthIndexedLine(lineString); double currentLength = 0d; while (currentLength < lineString.Length) { var tmpLine = (GeoAPI.Geometries.ILineString) lil.ExtractLine(currentLength, currentLength + length); ret.Add(tmpLine); currentLength += length; } return(lineString.Factory.CreateMultiLineString(ret.ToArray())); }
public void MlsLength() { Random rnd = new Random(); LineString[] ls = new LineString[40]; GeoAPI.Geometries.ILineString[] lscheck = new GeoAPI.Geometries.ILineString[40]; GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory(); for (int ii = 0; ii < 40; ii++) { Coordinate[] coord = new Coordinate[36]; GeoAPI.Geometries.ICoordinate[] coordcheck = new GeoAPI.Geometries.ICoordinate[36]; for (int i = 0; i < 36; i++) { coord[i] = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); double x = coord[i].X; double y = coord[i].Y; GisSharpBlog.NetTopologySuite.Geometries.Coordinate c = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y); coordcheck[i] = c; } ls[ii] = new LineString(coord); lscheck[ii] = gf.CreateLineString(coordcheck); } MultiLineString mls = new MultiLineString(ls); GeoAPI.Geometries.IMultiLineString mlscheck = gf.CreateMultiLineString(lscheck); Assert.AreEqual(mls.Length, mlscheck.Length); }
public void EnveloptMls() { var rnd = new Random(); var ls = new LineString[40]; var lscheck = new GeoAPI.Geometries.ILineString[40]; var gf = new NetTopologySuite.Geometries.GeometryFactory(); for (var ii = 0; ii < 40; ii++) { var coord = new Coordinate[36]; var coordcheck = new GeoAPI.Geometries.Coordinate[36]; for (var i = 0; i < 36; i++) { coord[i] = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); var x = coord[i].X; var y = coord[i].Y; var c = new GeoAPI.Geometries.Coordinate(x, y); coordcheck[i] = c; } ls[ii] = new LineString(coord); lscheck[ii] = gf.CreateLineString(coordcheck); } var mls = new MultiLineString(ls); var mlscheck = gf.CreateMultiLineString(lscheck); Assert.AreEqual(mls.Envelope.Width, mlscheck.EnvelopeInternal.Width); Assert.AreEqual(mls.Envelope.Height, mlscheck.EnvelopeInternal.Height); }
/// <summary> /// Method to render the arrow /// </summary> /// <param name="map">The map</param> /// <param name="graphics">The graphics object</param> /// <param name="arrow">The arrow</param> private void RenderArrow(SharpMap.Map map, System.Drawing.Graphics graphics, GeoAPI.Geometries.ILineString arrow) { var pts = new System.Drawing.PointF[arrow.Coordinates.Length]; for (var i = 0; i < pts.Length; i++) { pts[i] = map.WorldToImage(arrow.GetCoordinateN(i)); } graphics.DrawLines(ArrowPen, pts); }
public void LineStringCoordiantesCount() { Coordinate[] coords = new Coordinate[36]; Random rnd = new Random(); GeoAPI.Geometries.ICoordinate[] coordscheck = new GeoAPI.Geometries.ICoordinate[36]; for (int i = 0; i < 36; i++) { coords[i] = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); double x = coords[i].X; double y = coords[i].Y; GisSharpBlog.NetTopologySuite.Geometries.Coordinate c = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y); coordscheck[i] = c; } GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory(); GeoAPI.Geometries.ILineString lscheck = gf.CreateLineString(coordscheck); LineString ls = new LineString(coords); Assert.AreEqual(ls.Coordinates.Count, lscheck.Coordinates.Count()); }
public void LineStringEnvelopeHeightWidth() { Coordinate[] coords = new Coordinate[36]; Random rnd = new Random(); GeoAPI.Geometries.ICoordinate[] coordscheck = new GeoAPI.Geometries.ICoordinate[36]; for (int i = 0; i < 36; i++) { coords[i] = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); double x = coords[i].X; double y = coords[i].Y; GisSharpBlog.NetTopologySuite.Geometries.Coordinate c = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y); coordscheck[i] = c; } GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory(); GeoAPI.Geometries.ILineString lscheck = gf.CreateLineString(coordscheck); LineString ls = new LineString(coords); AssertExt.AreEqual15(ls.Envelope.Width, lscheck.EnvelopeInternal.Width); AssertExt.AreEqual15(ls.Envelope.Height, lscheck.EnvelopeInternal.Height); }
public void LineStringEnvelopeHeightWidth() { var coords = new Coordinate[36]; var rnd = new Random(); var coordscheck = new GeoAPI.Geometries.Coordinate[36]; for (var i = 0; i < 36; i++) { coords[i] = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); var x = coords[i].X; var y = coords[i].Y; var c = new GeoAPI.Geometries.Coordinate(x, y); coordscheck[i] = c; } var gf = new NetTopologySuite.Geometries.GeometryFactory(); GeoAPI.Geometries.ILineString lscheck = gf.CreateLineString(coordscheck); var ls = new LineString(coords); AssertExt.AreEqual15(ls.Envelope.Width, lscheck.EnvelopeInternal.Width); AssertExt.AreEqual15(ls.Envelope.Height, lscheck.EnvelopeInternal.Height); }