public void EnvelopeCoordinate() { Random rnd = new Random(); Coordinate c = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); Envelope ev = new Envelope(c); double x = c.X; double y = c.Y; GisSharpBlog.NetTopologySuite.Geometries.Coordinate ccheck = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y); GisSharpBlog.NetTopologySuite.Geometries.Envelope evcheck = new GisSharpBlog.NetTopologySuite.Geometries.Envelope(ccheck); AssertExt.AreEqual15(ev.Maximum.Y, evcheck.MaxY); AssertExt.AreEqual15(ev.Maximum.X, evcheck.MaxX); AssertExt.AreEqual15(ev.Minimum.Y, evcheck.MinY); AssertExt.AreEqual15(ev.Minimum.X, evcheck.MinX); }
public void TwoCoordinates() { Random rnd = new Random(); Coordinate c1 = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); Coordinate c2 = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); Envelope ev = new Envelope(c1, c2); double x1 = c1.X; double y1 = c1.Y; double x2 = c2.X; double y2 = c2.Y; GisSharpBlog.NetTopologySuite.Geometries.Coordinate c1Check = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x1, y1); GisSharpBlog.NetTopologySuite.Geometries.Coordinate c2Check = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x2, y2); GisSharpBlog.NetTopologySuite.Geometries.Envelope evcheck = new GisSharpBlog.NetTopologySuite.Geometries.Envelope(c1Check, c2Check); AssertExt.AreEqual15(ev.Maximum.Y, evcheck.MaxY); AssertExt.AreEqual15(ev.Maximum.X, evcheck.MaxX); AssertExt.AreEqual15(ev.Minimum.Y, evcheck.MinY); AssertExt.AreEqual15(ev.Minimum.X, evcheck.MinX); }
/// <summary> /// /// </summary> /// <param name="box"></param> /// <param name="ds"></param> public void ExecuteIntersectionQuery(SharpMap.Geometries.BoundingBox box, FeatureDataSet ds) { // Identifies all the features within the given BoundingBox GisSharpBlog.NetTopologySuite.Geometries.Envelope envelope = GeometryConverter.ToNTSEnvelope(box); List <GisSharpBlog.NetTopologySuite.Features.Feature> results = new List <GisSharpBlog.NetTopologySuite.Features.Feature>(features.Count); foreach (GisSharpBlog.NetTopologySuite.Features.Feature feature in features) { if (envelope.Intersects(feature.Geometry.EnvelopeInternal)) { results.Add(feature); } } // Fill DataSet SharpMap.Data.FeatureDataTable dataTable = CreateFeatureDataTable(); foreach (GisSharpBlog.NetTopologySuite.Features.Feature feature in results) { CreateNewRow(dataTable, feature); } ds.Tables.Add(dataTable); }
/// <summary> /// Returns the BoundingBox of the dataset. /// </summary> /// <returns>BoundingBox</returns> public SharpMap.Geometries.BoundingBox GetExtents() { GisSharpBlog.NetTopologySuite.Geometries.Envelope envelope = new GisSharpBlog.NetTopologySuite.Geometries.Envelope(); foreach (GisSharpBlog.NetTopologySuite.Features.Feature feature in features) envelope.ExpandToInclude(feature.Geometry.EnvelopeInternal); return GeometryConverter.ToSharpMapBoundingBox(envelope); }
/// <summary> /// Converts the <see cref="GisSharpBlog.NetTopologySuite.Geometries.Envelope"/> instance <paramref name="envelope"/> /// into a correspondant <see cref="SharpMap.Geometries.Geometry"/>. /// </summary> /// <param name="envelope"></param> /// <returns></returns> public static SharpMap.Geometries.Geometry ToSharpMapGeometry(GisSharpBlog.NetTopologySuite.Geometries.Envelope envelope) { return(ToSharpMapGeometry(new SharpMap.Geometries.BoundingBox(envelope.MinX, envelope.MinY, envelope.MaxX, envelope.MaxY))); }
/// <summary> /// NS 20032013 /// Determines if two boxes share, at least partially, a common border. /// </summary> /// <param name="box">The box to check</param> /// <returns>True if <paramref name="box"/> shares a commons border, false if not, or if either or both are empty.</returns> public bool Borders(GisSharpBlog.NetTopologySuite.Geometries.Envelope box1, GisSharpBlog.NetTopologySuite.Geometries.Envelope box2) { return(box1.MinX == box2.MinX || box1.MinY == box2.MinY || box1.MaxX == box2.MaxX || box1.MaxY == box2.MaxY); }
public RTreeIndexEntry(UInt32 key, GisSharpBlog.NetTopologySuite.Geometries.Envelope box) { _id = key; _box = box; }
public void HeightWidth() { Random rnd = new Random(); double x1 = ((rnd.NextDouble() * 360) - 180); double x2 = ((rnd.NextDouble() * 360) - 180); double y1 = ((rnd.NextDouble() * 360) - 180); double y2 = ((rnd.NextDouble() * 360) - 180); Envelope ev = new Envelope(x1, x2, y1, y2); GisSharpBlog.NetTopologySuite.Geometries.Envelope evcheck = new GisSharpBlog.NetTopologySuite.Geometries.Envelope(x1, x2, y1, y2); AssertExt.AreEqual15(ev.Height, evcheck.Height); AssertExt.AreEqual15(ev.Width, evcheck.Width); }
public void Center() { Random rnd = new Random(); Coordinate c1 = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); Coordinate c2 = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); Envelope ev = new Envelope(c1, c2); double x1 = c1.X; double y1 = c1.Y; double x2 = c2.X; double y2 = c2.Y; GisSharpBlog.NetTopologySuite.Geometries.Coordinate c1Check = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x1, y1); GisSharpBlog.NetTopologySuite.Geometries.Coordinate c2Check = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x2, y2); GisSharpBlog.NetTopologySuite.Geometries.Envelope evcheck = new GisSharpBlog.NetTopologySuite.Geometries.Envelope(c1Check, c2Check); Coordinate center = new Coordinate(ev.Center()); GisSharpBlog.NetTopologySuite.Geometries.Coordinate centercheck = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(evcheck.Centre); AssertExt.AreEqual15(center.X, centercheck.X); AssertExt.AreEqual15(center.Y, centercheck.Y); }