Class QuadTree<T>
A Quadtree is a spatial index structure for efficient range querying
of items bounded by 2D rectangles.
NetTopologySuite.Geometries.Geometrys can be indexed by using their NetTopologySuite.Geometries.Envelopes.
Any type of object can also be indexed, as long as it has an extent that can be represented by an NetTopologySuite.Geometries.Envelope. This Quadtree index provides a primary filter for range rectangle queries. The various query methods return a list of all items which may intersect the query rectangle. Note that it may thus return items which do not in fact intersect the query rectangle. A secondary filter is required to test for actual intersection between the query rectangle and the envelope of each candidate item. The secondary filter may be performed explicitly, or it may be provided implicitly by subsequent operations executed on the items (for instance, if the index query is followed by computing a spatial predicate between the query geometry and tree items, the envelope intersection check is performed automatically. This implementation does not require specifying the extent of the inserted items beforehand. It will automatically expand to accomodate any extent of dataset. This data structure is also known as an
NetTopologySuite.Geometries.Geometrys can be indexed by using their NetTopologySuite.Geometries.Envelopes.
Any type of object can also be indexed, as long as it has an extent that can be represented by an NetTopologySuite.Geometries.Envelope. This Quadtree index provides a primary filter for range rectangle queries. The various query methods return a list of all items which may intersect the query rectangle. Note that it may thus return items which do not in fact intersect the query rectangle. A secondary filter is required to test for actual intersection between the query rectangle and the envelope of each candidate item. The secondary filter may be performed explicitly, or it may be provided implicitly by subsequent operations executed on the items (for instance, if the index query is followed by computing a spatial predicate between the query geometry and tree items, the envelope intersection check is performed automatically. This implementation does not require specifying the extent of the inserted items beforehand. It will automatically expand to accomodate any extent of dataset. This data structure is also known as an
MX-CIF quadtree
following the terminology usage of Samet and others.
Inheritance
System.Object
QuadTree<T>
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Mars.Common.Collections
Assembly: Mars.Common.dll
Syntax
[Serializable]
public class QuadTree<T>
Type Parameters
Name | Description |
---|---|
T |
Constructors
| Improve this Doc View SourceQuadTree()
Creates a new empty QuadTree<T>.
Declaration
public QuadTree()
Properties
| Improve this Doc View SourceCount
Returns the number of items in the tree.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Depth
Returns the number of levels in the tree.
Declaration
public int Depth { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
IsEmpty
Tests whether the index contains any items.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceInsert(Envelope, T)
Declaration
public void Insert(Envelope itemEnv, T item)
Parameters
Type | Name | Description |
---|---|---|
NetTopologySuite.Geometries.Envelope | itemEnv | |
T | item |
Query(Envelope, Action<T>)
Queries the tree and visits items which may lie in the given search envelope.
Declaration
public void Query(Envelope searchEnv, Action<T> visitor)
Parameters
Type | Name | Description |
---|---|---|
NetTopologySuite.Geometries.Envelope | searchEnv | The envelope of the desired query area. |
System.Action<T> | visitor | A visitor object which is passed the visited items |
Remarks
Precisely, the items that are visited are all items in the tree
whose envelope may intersect the search Envelope.
Note that some items with non-intersecting envelopes may be visited as well;
the client is responsible for filtering these out.
In most situations there will be many items in the tree which do not
intersect the search envelope and which are not visited - thus
providing improved performance over a simple linear scan.
|
Improve this Doc
View Source
Query(Envelope)
Queries the tree and returns items which may lie in the given search envelope.
Declaration
public IList<T> Query(Envelope searchEnv)
Parameters
Type | Name | Description |
---|---|---|
NetTopologySuite.Geometries.Envelope | searchEnv | The envelope of the desired query area. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<T> | A List of items which may intersect the search envelope |
Remarks
Precisely, the items that are returned are all items in the tree
whose envelope may intersect the search Envelope.
Note that some items with non-intersecting envelopes may be returned as well;
the client is responsible for filtering these out.
In most situations there will be many items in the tree which do not
intersect the search envelope and which are not returned - thus
providing improved performance over a simple linear scan.
|
Improve this Doc
View Source
QueryAll()
Return a list of all items in the QuadTree<T>.
Declaration
public IList<T> QueryAll()
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<T> |
Remove(Envelope, T)
Removes a single item from the tree.
Declaration
public bool Remove(Envelope itemEnv, T item)
Parameters
Type | Name | Description |
---|---|---|
NetTopologySuite.Geometries.Envelope | itemEnv | The Envelope of the item to be removed. |
T | item | The item to remove. |
Returns
Type | Description |
---|---|
System.Boolean | true if the item was found (and thus removed). |