Package org.anchoranalysis.spatial.rtree
Class RTree<T>
Object
RTree<T>
- Type Parameters:
T- object-type stored in structure (the payload).
- Direct Known Subclasses:
BoundingBoxRTree,IntervalRTree
Bases class for implementations of R-Trees that store objects with associated geometry.
- Author:
- Owen Feehan
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdds aRectanglewith a corresponding payload.Any arbitrary element from the tree.asSet()All elements contained within the tree, as aSet.containsStream(com.github.davidmoten.rtreemulti.geometry.Point point) Which objects contain a particular point?intersectsWithStream(com.github.davidmoten.rtreemulti.geometry.Rectangle rectangle) A stream of the elements that a rectangle intersects with.booleanisEmpty()Returns true if and only if the R-tree is empty of entries.protected voidRemoves a particular item from the r-tree, identified by itsRectangleand payload.intsize()The total number of items stored in the tree.
-
Constructor Details
-
RTree
protected RTree(int numberDimensions) Creates an empty R-Tree.- Parameters:
numberDimensions- the number of spatial dimensions that the bounding boxes are expected to support.
-
RTree
protected RTree(int numberDimensions, int maxNumberEntries) Creates an empty R-Tree with a specified number of children.- Parameters:
numberDimensions- the number of spatial dimensions that the bounding boxes are expected to support.maxNumberEntries- maximum number of entries in the r-tree.
-
-
Method Details
-
size
public int size()The total number of items stored in the tree.- Returns:
- the total number of items.
-
asSet
All elements contained within the tree, as aSet.- Returns:
- a newly created
Setof all the elements, reusing the existing element objects.
-
arbitraryElement
Any arbitrary element from the tree.This method should never be called on an empty tree. Consider checking first with
isEmpty().- Returns:
- the element.
-
isEmpty
public boolean isEmpty()Returns true if and only if the R-tree is empty of entries.- Returns:
- is R-tree empty
-
add
Adds aRectanglewith a corresponding payload.Note that the payload must not be unique, and multiple identical elements can exist with the same bounding-box and payload.
- Parameters:
rectangle- the rectangle associated with the payload.payload- the payload associated with the rectangle.
-
containsStream
Which objects contain a particular point?- Parameters:
point- the point.- Returns:
- a stream of payloads for all objects that contain
point.
-
intersectsWithStream
protected Stream<T> intersectsWithStream(com.github.davidmoten.rtreemulti.geometry.Rectangle rectangle) A stream of the elements that a rectangle intersects with.- Parameters:
rectangle- the rectangle associated with the payload.- Returns:
- the stream.
-
remove
Removes a particular item from the r-tree, identified by itsRectangleand payload.If no entry can be found matching exactly the
rectangleandentry, no change happens to the r-tree. No error is reported.If multiple entries exist that match exactly the
rectangleandentry, then all entries are removed.- Parameters:
rectangle- the rectangle.payload- the payload.
-