distance method

double distance()

Computes the distance between the {@link Boundable}s in this pair. The boundables are either composites or leaves. If either is composite, the distance is computed as the minimum distance between the bounds. If both are leaves, the distance is computed by {@link #itemDistance(ItemBoundable, ItemBoundable)}.

@return

Implementation

double distance() {
  // if items, compute exact distance
  if (isLeaves()) {
    return itemDistance.distance(
        boundable1 as ItemBoundable, boundable2 as ItemBoundable);
  }
  // otherwise compute distance between bounds of boundables
  return (boundable1.getBounds() as Envelope)
      .distance((boundable2.getBounds() as Envelope));
}