Class Bintree

java.lang.Object
org.locationtech.jts.index.bintree.Bintree

public class Bintree extends Object
An BinTree (or "Binary Interval Tree") is a 1-dimensional version of a quadtree. It indexes 1-dimensional intervals (which may be the projection of 2-D objects on an axis). It supports range searching (where the range may be a single point). This structure is dynamic - new items can be added at any time, and it will support deletion of items (although this is not currently implemented).

This implementation does not require specifying the extent of the inserted items beforehand. It will automatically expand to accommodate any extent of dataset.

The bintree structure is used to provide a primary filter for interval queries. The query() method returns a list of all objects which may intersect the query interval. Note that it may return objects which do not in fact intersect. A secondary filter is required to test for exact intersection. Of course, this secondary filter may consist of other tests besides intersection, such as testing other kinds of spatial relationships.

This index is different to the Interval Tree of Edelsbrunner or the Segment Tree of Bentley.

Version:
1.7
  • Constructor Details

    • Bintree

      public Bintree()
  • Method Details

    • ensureExtent

      public static Interval ensureExtent(Interval itemInterval, double minExtent)
      Ensure that the Interval for the inserted item has non-zero extents. Use the current minExtent to pad it, if necessary
    • depth

      public int depth()
    • size

      public int size()
    • nodeSize

      public int nodeSize()
      Compute the total number of nodes in the tree
      Returns:
      the number of nodes in the tree
    • insert

      public void insert(Interval itemInterval, Object item)
    • remove

      public boolean remove(Interval itemInterval, Object item)
      Removes a single item from the tree.
      Parameters:
      itemInterval - the interval of the item to be removed
      item - the item to remove
      Returns:
      true if the item was found (and thus removed)
    • iterator

      public Iterator iterator()
    • query

      public List query(double x)
    • query

      public List query(Interval interval)
      Queries the tree to find all candidate items which may overlap the query interval. If the query interval is null, all items in the tree are found. min and max may be the same value
    • query

      public void query(Interval interval, Collection foundItems)
      Adds items in the tree which potentially overlap the query interval to the given collection. If the query interval is null, add all items in the tree.
      Parameters:
      interval - a query interval, or null
      foundItems - the candidate items found