/// <summary> /// Gets the object IDs in the view. /// </summary> /// <param name="bbox">The bbox.</param> /// <returns></returns> public Collection <uint> GetObjectIDsInView(SharpMap.Geometries.BoundingBox bbox) { // Identifies all the features within the given BoundingBox GisSharpBlog.NetTopologySuite.Geometries.Envelope envelope = GeometryConverter.ToNTSEnvelope(bbox); Collection <uint> geoms = new Collection <uint>(); for (int i = 0; i < features.Count; i++) { if (envelope.Intersects(features[i].Geometry.EnvelopeInternal)) { geoms.Add(Convert.ToUInt32(i)); } } return(geoms); }
/// <summary> /// Returns features within the specified bounding box. /// </summary> /// <param name="bbox"></param> /// <returns></returns> public Collection <SharpMap.Geometries.Geometry> GetGeometriesInView(SharpMap.Geometries.BoundingBox bbox) { // Identifies all the features within the given BoundingBox GisSharpBlog.NetTopologySuite.Geometries.Envelope envelope = GeometryConverter.ToNTSEnvelope(bbox); Collection <SharpMap.Geometries.Geometry> geoms = new Collection <SharpMap.Geometries.Geometry>(); foreach (GisSharpBlog.NetTopologySuite.Features.Feature feature in features) { if (envelope.Intersects(feature.Geometry.EnvelopeInternal)) { geoms.Add(GeometryConverter.ToSharpMapGeometry(feature.Geometry as GisSharpBlog.NetTopologySuite.Geometries.Geometry)); } } return(geoms); }
/// <summary> /// Recursive function that traverses the tree and looks for intersections with a given <see cref="BoundingBox">region</see>. /// </summary> /// <remarks> /// Nothing is added to the list if <paramref name="box"/> equals <see cref="BoundingBox.Empty"/>. /// </remarks> /// <param name="box">Boundingbox to intersect with</param> /// <param name="node">Node to search from</param> /// <param name="list">List of found intersections</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="node"/> is null or if <paramref name="list"/> is null.</exception> protected void IntersectTreeRecursive(GisSharpBlog.NetTopologySuite.Geometries.Envelope box, Node node, List <uint> list) { if (node == null) { throw new ArgumentNullException("node"); } if (list == null) { throw new ArgumentNullException("list"); } if (box == null) { return; } if (node is LeafNode) //Leaf has been reached { foreach (RTreeIndexEntry entry in (node as LeafNode).Entries) { if (entry.Box.Intersects(box)) { list.Add(entry.Id); } } } else if (node is IndexNode) { if (box.Intersects(node.Box)) { foreach (Node child in (node as IndexNode).Children) { IntersectTreeRecursive(box, child, list); } } } else { throw new InvalidOperationException("Unknown node type: " + node.GetType()); } }
/// <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); }