nearestNeighbourWithTree method

List<Object>? nearestNeighbourWithTree(
  1. STRtree tree,
  2. ItemDistance itemDist
)

Finds the two nearest items from this tree and another tree, using {@link ItemDistance} as the distance metric. A Branch-and-Bound tree traversal algorithm is used to provide an efficient search. The result value is a pair of items, the first from this tree and the second from the argument tree.

@param tree another tree @param itemDist a distance metric applicable to the items in the trees @return the pair of the nearest items, one from each tree or null if no pair of distinct items can be found

Implementation

List<Object>? nearestNeighbourWithTree(STRtree tree, ItemDistance itemDist) {
  if (isEmpty() || tree.isEmpty()) return null;
  BoundablePair bp =
      new BoundablePair(this.getRoot(), tree.getRoot(), itemDist);
  return nearestNeighbourWithPair(bp);
}