public void Overlaps() { Random rnd = new Random(); Polygon[] pg = new Polygon[50]; GeoAPI.Geometries.IPolygon[] pgcheck = new GeoAPI.Geometries.IPolygon[50]; GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory(); Coordinate center = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); for (int i = 0; i < 50; i++) { Coordinate[] coord = new Coordinate[36]; GeoAPI.Geometries.ICoordinate[] coordscheck = new GeoAPI.Geometries.ICoordinate[36]; for (int ii = 0; ii < 36; ii++) { coord[ii] = new Coordinate(center.X + Math.Cos((ii * 10) * Math.PI / 10), center.Y + (ii * 10) * Math.PI / 10); double x = coord[ii].X; double y = coord[ii].Y; GisSharpBlog.NetTopologySuite.Geometries.Coordinate c = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y); coordscheck[ii] = c; } coord[35] = new Coordinate(coord[0].X, coord[0].Y); coordscheck[35] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(coordscheck[0].X, coordscheck[0].Y); GeoAPI.Geometries.ILinearRing ring = gf.CreateLinearRing(coordscheck); pgcheck[i] = gf.CreatePolygon(ring, null); pg[i] = new Polygon(coord); } for (int t = 0; t < 49; t++) { bool g = pg[t].Overlaps(pg[t + 1]); bool gcheck = pgcheck[t].Overlaps(pgcheck[t + 1]); Assert.AreEqual(g, gcheck); } }
/// <summary> /// Initialize a new instance of the Text object /// </summary> /// <param name="Position">A Vector2d containg X and Y coordinates</param> /// <param name="Value">The text string itself</param> /// <param name="Layer">Layer name</param> /// <returns>A DXF Text object</returns> public Text(GeoAPI.Geometries.ICoordinate Location, string Value, string Layer, string Handle) { this.Location = Location; this.Value = Value; this.Layer = Layer; this.Handle = Handle; }
public void PolygonEnvelopeMaxMin() { Coordinate[] coords = new Coordinate[20]; Random rnd = new Random(); Coordinate center = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); GeoAPI.Geometries.ICoordinate[] coordscheck = new GeoAPI.Geometries.ICoordinate[20]; for (int i = 0; i < 19; i++) { coords[i] = new Coordinate(center.X + Math.Cos((i * 10) * Math.PI / 10), center.Y + (i * 10) * Math.PI / 10); 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; } coordscheck[19] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(coords[0].X, coords[0].Y); coords[19] = new Coordinate(coords[0].X, coords[0].Y); GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory(); GeoAPI.Geometries.ILinearRing ring = gf.CreateLinearRing(coordscheck); GeoAPI.Geometries.IPolygon pgcheck = gf.CreatePolygon(ring, null); Polygon pg = new Polygon(coords); AssertExt.AreEqual15(pg.Envelope.Maximum.X, pgcheck.EnvelopeInternal.MaxX); AssertExt.AreEqual15(pg.Envelope.Maximum.Y, pgcheck.EnvelopeInternal.MaxY); AssertExt.AreEqual15(pg.Envelope.Minimum.X, pgcheck.EnvelopeInternal.MinX); AssertExt.AreEqual15(pg.Envelope.Minimum.Y, pgcheck.EnvelopeInternal.MinY); }
/// <summary> /// Initialize a new instance of the Circle object /// </summary> /// <param name="Center">A Vector2d containg X and Y center coordinates</param> /// <param name="Radius">Circle radius</param> /// <param name="Layer">Layer name</param> /// <returns>A DXF Circle object</returns> public Circle(GeoAPI.Geometries.ICoordinate Center, double Radius, string Layer, string Handle) { this.Center = Center; this.Radius = Radius; this.Layer = Layer; this.Handle = Handle; }
public void Multipg() { Random rnd = new Random(); Polygon[] pg = new Polygon[50]; GeoAPI.Geometries.IPolygon[] pgcheck = new GeoAPI.Geometries.IPolygon[50]; GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory(); for (int i = 0; i < 50; i++) { Coordinate center = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); Coordinate[] coord = new Coordinate[36]; GeoAPI.Geometries.ICoordinate[] coordscheck = new GeoAPI.Geometries.ICoordinate[36]; for (int ii = 0; ii < 36; ii++) { coord[ii] = new Coordinate(center.X + Math.Cos((ii * 10) * Math.PI / 10), center.Y + (ii * 10) * Math.PI / 10); double x = coord[ii].X; double y = coord[ii].Y; GisSharpBlog.NetTopologySuite.Geometries.Coordinate c = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y); coordscheck[ii] = c; } coord[35] = new Coordinate(coord[0].X, coord[0].Y); coordscheck[35] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(coordscheck[0].X, coordscheck[0].Y); GeoAPI.Geometries.ILinearRing ring = gf.CreateLinearRing(coordscheck); pgcheck[i] = gf.CreatePolygon(ring, null); pg[i] = new Polygon(coord); } MultiPolygon mpg = new MultiPolygon(pg); GeoAPI.Geometries.IMultiPolygon mpgcheck = gf.CreateMultiPolygon(pgcheck); for (int ii = 0; ii < mpg.Coordinates.Count; ii++) { Assert.AreEqual(mpg.Coordinates[ii].X, mpgcheck.Coordinates[ii].X); Assert.AreEqual(mpg.Coordinates[ii].Y, mpgcheck.Coordinates[ii].Y); } }
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 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 MpsBufferArea() { Coordinate[] c = new Coordinate[36]; Random rnd = new Random(); GeoAPI.Geometries.ICoordinate[] ccheck = new GeoAPI.Geometries.ICoordinate[36]; GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory(); for (int i = 0; i < 36; i++) { c[i] = new Coordinate((rnd.NextDouble() + 360) - 180, (rnd.NextDouble() * 180) - 90); double x = c[i].X; double y = c[i].Y; GisSharpBlog.NetTopologySuite.Geometries.Coordinate ctemp = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y); ccheck[i] = ctemp; } GeoAPI.Geometries.IMultiPoint mpsCheck = gf.CreateMultiPoint(ccheck); MultiPoint mps = new MultiPoint(c); double area = mps.Buffer(500).Area; double areacheck = mpsCheck.Buffer(500).Area; if (Math.Abs(area - areacheck) > 0.000000001) { Assert.AreEqual(mps.Buffer(500).Area, mpsCheck.Buffer(500).Area); } }
public void PolygonArea() { Coordinate[] coords = new Coordinate[20]; Random rnd = new Random(); Coordinate center = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); GeoAPI.Geometries.ICoordinate[] coordscheck = new GeoAPI.Geometries.ICoordinate[20]; for (int i = 0; i < 19; i++) { coords[i] = new Coordinate(center.X + Math.Cos((i * 10) * Math.PI / 10), center.Y + (i * 10) * Math.PI / 10); 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; } coordscheck[19] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(coordscheck[0].X, coordscheck[0].Y); coords[19] = new Coordinate(coords[0].X, coords[0].Y); GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory(); GeoAPI.Geometries.ILinearRing ring = gf.CreateLinearRing(coordscheck); GeoAPI.Geometries.IPolygon polygonCheck = gf.CreatePolygon(ring, null); Polygon pg = new Polygon(coords); double areaCheck = polygonCheck.Area; double area = pg.Area; Assert.AreEqual(area, areaCheck); }
public void Multipg() { Random rnd = new Random(); Polygon[] pg = new Polygon[50]; GeoAPI.Geometries.IPolygon[] pgcheck = new GeoAPI.Geometries.IPolygon[50]; GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory(); for (int i = 0; i < 50; i++) { Coordinate center = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); Coordinate[] coord = new Coordinate[36]; GeoAPI.Geometries.ICoordinate[] coordscheck = new GeoAPI.Geometries.ICoordinate[36]; for (int ii = 0; ii < 36; ii++) { coord[ii] = new Coordinate(center.X + Math.Cos((ii * 10) * Math.PI / 10), center.Y + (ii * 10) * Math.PI / 10); double x = coord[ii].X; double y = coord[ii].Y; GisSharpBlog.NetTopologySuite.Geometries.Coordinate c = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y); coordscheck[ii] = c; } coord[35] = new Coordinate(coord[0].X, coord[0].Y); coordscheck[35] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(coordscheck[0].X, coordscheck[0].Y); GeoAPI.Geometries.ILinearRing ring = gf.CreateLinearRing(coordscheck); pgcheck[i] = gf.CreatePolygon(ring, null); pg[i] = new Polygon(coord); } MultiPolygon mpg = new MultiPolygon(pg); GeoAPI.Geometries.IMultiPolygon mpgcheck = gf.CreateMultiPolygon(pgcheck); for (int ii = 0; ii < mpg.Coordinates.Count; ii++) { Assert.AreEqual(mpg.Coordinates[ii].X, mpgcheck.Coordinates[ii].X); Assert.AreEqual(mpg.Coordinates[ii].Y, mpgcheck.Coordinates[ii].Y); } }
public void OnMouseUp(GeoAPI.Geometries.ICoordinate worldPosition, System.Windows.Forms.MouseEventArgs e) { if (enabled) { MessageBox.Show("Hallo Rob", "Demo MapTool"); } }
public GeoAPI.Geometries.ICoordinate CrossProduct(GeoAPI.Geometries.ICoordinate u, GeoAPI.Geometries.ICoordinate v) { double a = u.Y * v.Z - u.Z * v.Y; double b = u.Z * v.X - u.X * v.Z; double c = u.X * v.Y - u.Y * v.X; GeoAPI.Geometries.ICoordinate coord = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(a, b, c); return(coord); }
public void PolygonHoles() { Coordinate[] coords = new Coordinate[20]; Random rnd = new Random(); Coordinate center = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); // Shell Coordinates GeoAPI.Geometries.ICoordinate[] coordscheck = new GeoAPI.Geometries.ICoordinate[20]; for (int i = 0; i < 19; i++) { double x = center.X + Math.Cos((i * 10) * Math.PI / 10); double y = center.Y + (i * 10) * Math.PI / 10; coords[i] = new Coordinate(x, y); coordscheck[i] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y); } coordscheck[19] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(coords[0].X, coords[0].Y); coords[19] = new Coordinate(coords[0].X, coords[0].Y); // Shell Rings LinearRing ring = new LinearRing(coords); GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory(); GeoAPI.Geometries.ILinearRing ringCheck = gf.CreateLinearRing(coordscheck); // Hole Coordinates GeoAPI.Geometries.ICoordinate[] coordsholecheck = new GeoAPI.Geometries.ICoordinate[20]; Coordinate[] coordshole = new Coordinate[20]; for (int i = 0; i < 20; i++) { double x = center.X + Math.Cos((i * 10) * Math.PI / 20); double y = center.Y + (i * 10) * Math.PI / 20; coordshole[i] = new Coordinate(x, y); coordsholecheck[i] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y); } coordshole[19] = new Coordinate(coordshole[0].X, coordshole[0].Y); coordsholecheck[19] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(coordshole[0].X, coordshole[0].Y); // Hole LinearRing Arrays LinearRing hole = new LinearRing(coordshole); ILinearRing[] holes = new ILinearRing[1]; GeoAPI.Geometries.ILinearRing holeCheck = gf.CreateLinearRing(coordsholecheck); GeoAPI.Geometries.ILinearRing[] holescheck = new GeoAPI.Geometries.ILinearRing[1]; holes[0] = hole; holescheck[0] = holeCheck; Polygon pg = new Polygon(ring, holes); GeoAPI.Geometries.IPolygon polygonCheck = gf.CreatePolygon(ringCheck, holescheck); double areaCheck = polygonCheck.Area; double area = pg.Area; Assert.AreEqual(area, areaCheck); }
/// <summary> /// Initialize a new instance of the Arc object /// </summary> /// <param name="Center">A Vector2d containg X and Y center coordinates</param> /// <param name="Radius">Arc radius</param> /// <param name="StartAng">Starting angle, in degrees</param> /// <param name="EndAng">Ending angle, in degrees</param> /// <param name="Layer">Layer name</param> /// <returns>A DXF Arc object</returns> public Arc(GeoAPI.Geometries.ICoordinate Center, double Radius, double StartAng, double EndAng, string Layer, string Handle) { this.Center = Center; this.Radius = Radius; this.StartAngle = StartAng; this.EndAngle = EndAng; this.Layer = Layer; this.Handle = Handle; }
public void PolygonHoles() { Coordinate[] coords = new Coordinate[20]; Random rnd = new Random(); Coordinate center = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); // Shell Coordinates GeoAPI.Geometries.ICoordinate[] coordscheck = new GeoAPI.Geometries.ICoordinate[20]; for (int i = 0; i < 19; i++) { double x = center.X + Math.Cos((i * 10) * Math.PI / 10); double y = center.Y + (i * 10) * Math.PI / 10; coords[i] = new Coordinate(x, y); coordscheck[i] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y); } coordscheck[19] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(coords[0].X, coords[0].Y); coords[19] = new Coordinate(coords[0].X, coords[0].Y); // Shell Rings LinearRing ring = new LinearRing(coords); GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory(); GeoAPI.Geometries.ILinearRing ringCheck = gf.CreateLinearRing(coordscheck); // Hole Coordinates GeoAPI.Geometries.ICoordinate[] coordsholecheck = new GeoAPI.Geometries.ICoordinate[20]; Coordinate[] coordshole = new Coordinate[20]; for (int i = 0; i < 20; i++) { double x = center.X + Math.Cos((i * 10) * Math.PI / 20); double y = center.Y + (i * 10) * Math.PI / 20; coordshole[i] = new Coordinate(x, y); coordsholecheck[i] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y); } coordshole[19] = new Coordinate(coordshole[0].X, coordshole[0].Y); coordsholecheck[19] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(coordshole[0].X, coordshole[0].Y); // Hole LinearRing Arrays LinearRing hole = new LinearRing(coordshole); ILinearRing[] holes = new ILinearRing[1]; GeoAPI.Geometries.ILinearRing holeCheck = gf.CreateLinearRing(coordsholecheck); GeoAPI.Geometries.ILinearRing[] holescheck = new GeoAPI.Geometries.ILinearRing[1]; holes[0] = hole; holescheck[0] = holeCheck; Polygon pg = new Polygon(ring, holes); GeoAPI.Geometries.IPolygon polygonCheck = gf.CreatePolygon(ringCheck, holescheck); double areaCheck = polygonCheck.Area; double area = pg.Area; Assert.AreEqual(area, areaCheck); }
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 LineLength() { 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); double length = ls.Length; double lengthcheck = lscheck.Length; Assert.AreEqual(length, lengthcheck); }
public void MultiPs() { Coordinate[] c = new Coordinate[36]; Random rnd = new Random(); GeoAPI.Geometries.ICoordinate[] ccheck = new GeoAPI.Geometries.ICoordinate[36]; GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory(); for (int i = 0; i < 36; i++) { c[i] = new Coordinate((rnd.NextDouble() + 360) - 180, (rnd.NextDouble() * 180) - 90); double x = c[i].X; double y = c[i].Y; GisSharpBlog.NetTopologySuite.Geometries.Coordinate ctemp = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y); ccheck[i] = ctemp; } GeoAPI.Geometries.IMultiPoint mpsCheck = gf.CreateMultiPoint(ccheck); MultiPoint mps = new MultiPoint(c); for (int ii = 0; ii < mps.Coordinates.Count; ii++) { Assert.AreEqual(mps.Coordinates[ii].X, mpsCheck.Coordinates[ii].X); Assert.AreEqual(mps.Coordinates[ii].Y, mpsCheck.Coordinates[ii].Y); } }
public void MultiPs() { Coordinate[] c = new Coordinate[36]; Random rnd = new Random(); GeoAPI.Geometries.ICoordinate[] ccheck = new GeoAPI.Geometries.ICoordinate[36]; GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory(); for (int i = 0; i < 36; i++) { c[i] = new Coordinate((rnd.NextDouble() + 360) - 180, (rnd.NextDouble() * 180) - 90); double x = c[i].X; double y = c[i].Y; GisSharpBlog.NetTopologySuite.Geometries.Coordinate ctemp = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y); ccheck[i] = ctemp; } GeoAPI.Geometries.IMultiPoint mpsCheck = gf.CreateMultiPoint(ccheck); MultiPoint mps = new MultiPoint(c); for (int ii = 0; ii < mps.Coordinates.Count; ii++) { Assert.AreEqual(mps.Coordinates[ii].X, mpsCheck.Coordinates[ii].X); Assert.AreEqual(mps.Coordinates[ii].Y, mpsCheck.Coordinates[ii].Y); } }
public void PolygonArea() { Coordinate[] coords = new Coordinate[20]; Random rnd = new Random(); Coordinate center = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); GeoAPI.Geometries.ICoordinate[] coordscheck = new GeoAPI.Geometries.ICoordinate[20]; for (int i = 0; i < 19; i++) { coords[i] = new Coordinate(center.X + Math.Cos((i * 10) * Math.PI / 10), center.Y + (i * 10) * Math.PI / 10); 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; } coordscheck[19] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(coordscheck[0].X, coordscheck[0].Y); coords[19] = new Coordinate(coords[0].X, coords[0].Y); GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory(); GeoAPI.Geometries.ILinearRing ring = gf.CreateLinearRing(coordscheck); GeoAPI.Geometries.IPolygon polygonCheck = gf.CreatePolygon(ring, null); Polygon pg = new Polygon(coords); double areaCheck = polygonCheck.Area; double area = pg.Area; Assert.AreEqual(area, areaCheck); }
public void OnMouseHover(GeoAPI.Geometries.ICoordinate worldPosition, EventArgs e) { }
public void OnMouseWheel(GeoAPI.Geometries.ICoordinate worldPosition, System.Windows.Forms.MouseEventArgs e) { }
public void SetCentre(GeoAPI.Geometries.ICoordinate centre, double width, double height) { throw new NotImplementedException(); }
public void OnBeforeContextMenu(System.Windows.Forms.ContextMenuStrip menu, GeoAPI.Geometries.ICoordinate worldPosition) { }
public void SetCentre(GeoAPI.Geometries.ICoordinate centre) { throw new NotImplementedException(); }
public GeoAPI.Geometries.IEnvelope Union(GeoAPI.Geometries.ICoordinate coord) { throw new NotImplementedException(); }
public bool Covers(GeoAPI.Geometries.ICoordinate p) { throw new NotImplementedException(); }
public void ExpandToInclude(GeoAPI.Geometries.ICoordinate p) { throw new NotImplementedException(); }
public void Init(GeoAPI.Geometries.ICoordinate p1, GeoAPI.Geometries.ICoordinate p2) { throw new NotImplementedException(); }
public static double DotProduct(GeoAPI.Geometries.ICoordinate u, GeoAPI.Geometries.ICoordinate v) { return((u.X * v.X) + (u.Y * v.Y) + (u.Z * v.Z)); }
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 MpsBufferArea() { Coordinate[] c = new Coordinate[36]; Random rnd = new Random(); GeoAPI.Geometries.ICoordinate[] ccheck = new GeoAPI.Geometries.ICoordinate[36]; GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory(); for (int i = 0; i < 36; i++) { c[i] = new Coordinate((rnd.NextDouble() + 360) - 180, (rnd.NextDouble() * 180) - 90); double x = c[i].X; double y = c[i].Y; GisSharpBlog.NetTopologySuite.Geometries.Coordinate ctemp = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y); ccheck[i] = ctemp; } GeoAPI.Geometries.IMultiPoint mpsCheck = gf.CreateMultiPoint(ccheck); MultiPoint mps = new MultiPoint(c); double area = mps.Buffer(500).Area; double areacheck = mpsCheck.Buffer(500).Area; if (Math.Abs(area - areacheck) > 0.000000001) { Assert.AreEqual(mps.Buffer(500).Area, mpsCheck.Buffer(500).Area); } }
public void PolygonEnvelopeMaxMin() { Coordinate[] coords = new Coordinate[20]; Random rnd = new Random(); Coordinate center = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); GeoAPI.Geometries.ICoordinate[] coordscheck = new GeoAPI.Geometries.ICoordinate[20]; for (int i = 0; i < 19; i++) { coords[i] = new Coordinate(center.X + Math.Cos((i * 10) * Math.PI / 10), center.Y + (i * 10) * Math.PI / 10); 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; } coordscheck[19] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(coords[0].X, coords[0].Y); coords[19] = new Coordinate(coords[0].X, coords[0].Y); GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory(); GeoAPI.Geometries.ILinearRing ring = gf.CreateLinearRing(coordscheck); GeoAPI.Geometries.IPolygon pgcheck = gf.CreatePolygon(ring, null); Polygon pg = new Polygon(coords); AssertExt.AreEqual15(pg.Envelope.Maximum.X, pgcheck.EnvelopeInternal.MaxX); AssertExt.AreEqual15(pg.Envelope.Maximum.Y, pgcheck.EnvelopeInternal.MaxY); AssertExt.AreEqual15(pg.Envelope.Minimum.X, pgcheck.EnvelopeInternal.MinX); AssertExt.AreEqual15(pg.Envelope.Minimum.Y, pgcheck.EnvelopeInternal.MinY); }
public void Overlaps() { Random rnd = new Random(); Polygon[] pg = new Polygon[50]; GeoAPI.Geometries.IPolygon[] pgcheck = new GeoAPI.Geometries.IPolygon[50]; GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory(); Coordinate center = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); for (int i = 0; i < 50; i++) { Coordinate[] coord = new Coordinate[36]; GeoAPI.Geometries.ICoordinate[] coordscheck = new GeoAPI.Geometries.ICoordinate[36]; for (int ii = 0; ii < 36; ii++) { coord[ii] = new Coordinate(center.X + Math.Cos((ii * 10) * Math.PI / 10), center.Y + (ii * 10) * Math.PI / 10); double x = coord[ii].X; double y = coord[ii].Y; GisSharpBlog.NetTopologySuite.Geometries.Coordinate c = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y); coordscheck[ii] = c; } coord[35] = new Coordinate(coord[0].X, coord[0].Y); coordscheck[35] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(coordscheck[0].X, coordscheck[0].Y); GeoAPI.Geometries.ILinearRing ring = gf.CreateLinearRing(coordscheck); pgcheck[i] = gf.CreatePolygon(ring, null); pg[i] = new Polygon(coord); } for (int t = 0; t < 49; t++) { bool g = pg[t].Overlaps(pg[t + 1]); bool gcheck = pgcheck[t].Overlaps(pgcheck[t + 1]); Assert.AreEqual(g, gcheck); } }
/// <summary> /// Initialize a new instance of the Point object /// </summary> /// <param name="Position">A Vector2d containg X and Y coordinates</param> /// <param name="Layer">Layer name</param> /// <returns>A DXF Point object</returns> public Point(GeoAPI.Geometries.ICoordinate Location, string Layer, string Handle) { this.Location = Location; this.Layer = Layer; this.Handle = Handle; }