- Type Parameters:
E- the type of elements stored in this tree.
PointTreeas arbitrary non-null objects with their coordinates computed by a user-specified
locatorfunction. That function expects an element
Ein argument and returns its coordinates as a
doublearray. The coordinates of each elements must be stable, i.e. applying the
locatorfunction twice on the same element must return the same coordinates. Searches based on element coordinates can be done with the following methods:
PointTreedepends on two parameters: an estimated bounding box of the points to be added in this tree and a maximal capacity of leaf nodes (not to be confused with a capacity of the tree). More details are given in the constructor.
Thread-safetyThis class is not thread-safe when the tree content is modified. But if the tree is kept unmodified after construction, then multiple read operations in concurrent threads are safe. Users can synchronize with
ReadWriteLock(the read lock must be held for complete duration of iterations or stream consumptions).
SerializationThis tree is serializable if the
locatorfunction and all elements in the tree are also serializable. However the serialization details is implementation specific and may change in any future Apache SIS version.
LimitationsCurrent implementation does not yet support removal of elements.
ReferencesInsertion algorithm is based on design of QuadTree index in H. Samet, The Design and Analysis of Spatial Data Structures. Massachusetts: Addison Wesley Publishing Company, 1989.
- See Also:
Defined in the
Nested Class Summary
Field SummaryModifier and TypeFieldDescription
static final intThe maximum number of dimensions (inclusive) that this class currently supports.
(Class<E> elementType, Envelope bounds, PointTree.Locator<? super E> locator, int nodeCapacity, boolean parallel)Creates an initially empty k-dimensional tree with the given capacity for each node.Creates a new tree initialized to a copy of the given tree.
Method SummaryModifier and TypeMethodDescription
booleanInserts the specified element into this tree if it is not already present.
booleanInserts all elements from the specified collection into this tree if they are not already present.
clear()Removes all elements from this tree.
trueif this set contains the specified element.Returns the coordinate reference system (CRS) of all points in this tree.
final intReturns the number of dimensions of points in this tree.Returns the base type of all elements in this tree.
isEmpty()Returns true if this set contains no elements.
iterator()Creates an iterator over all elements in this set.Returns a possibly parallel stream with this tree as its source.Returns all elements in the given bounding box.
size()Returns the number of elements in this tree.Creates an iterator over all elements in this set.
Methods inherited from class AbstractCollection
containsAll, remove, retainAll, toArray, toArray, toString
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
PointTreeCreates a new tree initialized to a copy of the given tree. This copy constructor shares some data structure from the
othertree for reducing memory usage, but the two trees are nevertheless independent (changes in a tree does not affect the other tree).
other- the other tree to copy.
(Class<E> elementType, Envelope bounds, PointTree.Locator<? super E> locator, int nodeCapacity, boolean parallel)Creates an initially empty k-dimensional tree with the given capacity for each node. The number of dimensions of the given envelope determines the number of dimensions of points in this tree. The positions computed by
locatormust have the same number of dimensions than the given envelope.
boundsargument specifies the expected region of points to be added in this
PointTree. Those bounds do not need to be exact;
PointTreewill work even if some points are located outside those bounds. However performances will be better if the envelope center is close to the median of the points to be inserted in the
PointTree, and if the majority of points are inside those bounds.
nodeCapacityis a threshold value controlling when the content of a node should be splited into smaller children nodes. That capacity should be a relatively small number, for example 10. Determining the most efficient value may require benchmarking.
elementType- the base type of all elements in this tree.
bounds- bounds of the region of data to be inserted in the k-dimensional tree.
locator- function computing the position of any element in this tree.
nodeCapacity- the capacity of each node (not to be confused with a capacity of the tree).
parallel- whether the stream can be parallel by default. Should be
falseif the given
locatoris not thread-safe.
getCoordinateReferenceSystemReturns the coordinate reference system (CRS) of all points in this tree. The CRS is taken from the envelope given in argument to the constructor.
- the CRS of all points in this tree, if presents.
- See Also:
getDimensionpublic final int getDimension()Returns the number of dimensions of points in this tree.
- the number of dimensions of points in this tree.
- See Also:
getElementTypeReturns the base type of all elements in this tree.
clearpublic void clear()Removes all elements from this tree.
isEmptypublic boolean isEmpty()Returns true if this set contains no elements.
sizepublic int size()Returns the number of elements in this tree.
addpublic boolean add
(E element)Inserts the specified element into this tree if it is not already present.
- Specified by:
- Specified by:
element- the element to insert.
trueif the element has been added, or
falseif it was already present.
NullPointerException- if the given element is null.
addAllInserts all elements from the specified collection into this tree if they are not already present.
containspublic boolean contains
trueif this set contains the specified element.
iteratorCreates an iterator over all elements in this set. In current implementation, the iterator does not support element removal.
spliteratorCreates an iterator over all elements in this set. The iterator characteristics are sized, distinct and
parallelStreamReturns a possibly parallel stream with this tree as its source. It is allowable for this method to return a sequential stream.
queryByBoundingBoxReturns all elements in the given bounding box. The given envelope shall be in the same CRS than the points in this tree (this is currently not verified). The returned stream may be parallel by default, depending on the argument given to the constructor. If the action to be applied on the stream can not be parallel, then user should invoke
searchRegion- envelope representing the rectangular search region.
- elements that are in the given search region (bounds inclusive).