Class RStarTree<T extends RNode>

  • Type Parameters:
    T -
    All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<T>, java.util.Collection<T>, RTreeInterface<T>

    public class RStarTree<T extends RNode>
    extends AbstractRTree<T>
    implements RTreeInterface<T>, java.io.Serializable
    TODO Must work for arbitrary dimension --- check that there's no 2D-specific stuff! An in-memory implementation of R*-tree.

    All items must have the same dimension.

    Only leaf nodes may be inserted.

    Since:
    12.2
    See Also:
    Serialized Form
    • Field Detail

      • rootReinserts

        protected long rootReinserts
      • rootSplits

        protected long rootSplits
      • nodesReinserted

        protected long nodesReinserted
      • nodesReinsertedSame

        protected long nodesReinsertedSame
      • nodesSplit

        protected long nodesSplit
      • nodesOverflowed

        protected long nodesOverflowed
      • assessSplitsCalls

        protected long assessSplitsCalls
    • Constructor Detail

      • RStarTree

        public RStarTree​(int dim,
                         int minFill,
                         int maxFill)
      • RStarTree

        public RStarTree​(int dim)
      • RStarTree

        public RStarTree​(int dim,
                         java.util.stream.Stream<? extends T> preload)
      • RStarTree

        public RStarTree​(int dim,
                         java.util.Collection<? extends T> c)
    • Method Detail

      • size

        public int size()
        Description copied from interface: RTreeInterface
        Gives the size of the tree.
        Specified by:
        size in interface java.util.Collection<T extends RNode>
        Specified by:
        size in interface RTreeInterface<T extends RNode>
        Specified by:
        size in class java.util.AbstractCollection<T extends RNode>
        Returns:
        the number of data nodes in the tree.
      • getRoot

        public oracle.spatial.geometry.RStarTree.RStarInternal getRoot()
        Specified by:
        getRoot in class AbstractRTree<T extends RNode>
      • add

        public boolean add​(T node)
                    throws java.lang.UnsupportedOperationException
        Description copied from interface: RTreeInterface
        Insert a new node into an RTree.

        Note that node.getMer() will be called repeatedly during RTree operations and should be efficient, typically implemented by the node caching a Mer which it returns on each call.

        node.isData() must return true.

        Specified by:
        add in interface java.util.Collection<T extends RNode>
        Specified by:
        add in interface RTreeInterface<T extends RNode>
        Overrides:
        add in class java.util.AbstractCollection<T extends RNode>
        Parameters:
        node - the node to insert
        Throws:
        java.lang.UnsupportedOperationException - if the tree does not support insertions
      • remove

        public boolean remove​(java.lang.Object obj)
                       throws java.lang.UnsupportedOperationException,
                              java.util.NoSuchElementException
        Specified by:
        remove in interface java.util.Collection<T extends RNode>
        Overrides:
        remove in class java.util.AbstractCollection<T extends RNode>
        Throws:
        java.lang.UnsupportedOperationException
        java.util.NoSuchElementException
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.util.Collection<T extends RNode>
        Specified by:
        iterator in interface java.lang.Iterable<T extends RNode>
        Specified by:
        iterator in class java.util.AbstractCollection<T extends RNode>
      • removeIf

        public boolean removeIf​(java.util.function.Predicate<? super Mer> merFilter,
                                java.util.function.Predicate<? super T> filter)
                         throws java.lang.UnsupportedOperationException
        Description copied from interface: RTreeInterface
        Remove all nodes for which merFilter and filter are both true. The merFilter is used to reduce the search space. See note on merFilter in the javadoc for this interface. There are no restrictions on the tests done by filter, as it is only applied to the data nodes.

        Most users should instead use the simpler removeIf(Mer, Predicate).

        For example, if tree is an RTree<JGeometry>, we could remove all geometries smaller than 1000 m^2 that are completely contained in the Western hemisphere: Mer westHemi = new Mer(2); westHemi.extend(-180, -90); westHemi.extend( 0, +90); tree.removeIf(x -> westHemi.interacts(x), x -> westHemi.covers(x) && x.area(0.001) < 1000); Note that westHemi.covers(x) violates the merFilter requirements and must be put in the filter predicate instead.

        Specified by:
        removeIf in interface RTreeInterface<T extends RNode>
        Parameters:
        merFilter - restricts the search area
        filter - the test for determining whether to remove a node
        Returns:
        true if any elements were removed
        Throws:
        java.lang.UnsupportedOperationException - if remove is not supported