nearestNeighbourWithEnvelope method

Object nearestNeighbourWithEnvelope(
  1. Envelope env,
  2. Object item,
  3. ItemDistance itemDist
)

Finds the item in this tree which is nearest to the given {@link Object}, using {@link ItemDistance} as the distance metric. A Branch-and-Bound tree traversal algorithm is used to provide an efficient search.

The query object does not have to be contained in the tree, but it does have to be compatible with the itemDist distance metric.

@param env the envelope of the query item @param item the item to find the nearest neighbour of @param itemDist a distance metric applicable to the items in this tree and the query item @return the nearest item in this tree or null if the tree is empty

Implementation

Object nearestNeighbourWithEnvelope(
    Envelope env, Object item, ItemDistance itemDist) {
  Boundable bnd = new ItemBoundable(env, item);
  BoundablePair bp = new BoundablePair(this.getRoot(), bnd, itemDist);
  return nearestNeighbourWithPair(bp)![0];
}