/** * 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 */ private double distance() { // if items, compute exact distance if (isLeaves()) { return itemDistance.distance((ItemBoundable) boundable1, (ItemBoundable) boundable2); } // otherwise compute distance between bounds of boundables return ((Envelope) boundable1.getBounds()).distance( ((Envelope) boundable2.getBounds())); }