Class BoundablePair
- java.lang.Object
-
- org.locationtech.jts.index.strtree.BoundablePair
-
- All Implemented Interfaces:
java.lang.Comparable
class BoundablePair extends java.lang.Object implements java.lang.Comparable
A pair ofBoundable
s, whose leaf items support a distance metric between them. Used to compute the distance between the members, and to expand a member relative to the other in order to produce new branches of the Branch-and-Bound evaluation tree. Provides an ordering based on the distance between the members, which allows building a priority queue by minimum distance.
-
-
Field Summary
Fields Modifier and Type Field Description private Boundable
boundable1
private Boundable
boundable2
private double
distance
private ItemDistance
itemDistance
-
Constructor Summary
Constructors Constructor Description BoundablePair(Boundable boundable1, Boundable boundable2, ItemDistance itemDistance)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static double
area(Boundable b)
int
compareTo(java.lang.Object o)
Compares two pairs based on their minimum distancesprivate double
distance()
Computes the distance between theBoundable
s in this pair.private void
expand(Boundable bndComposite, Boundable bndOther, PriorityQueue priQ, double minDistance)
void
expandToQueue(PriorityQueue priQ, double minDistance)
For a pair which is not a leaf (i.e.Boundable
getBoundable(int i)
Gets one of the memberBoundable
s in the pair (indexed by [0, 1]).double
getDistance()
Gets the minimum possible distance between the Boundables in this pair.static boolean
isComposite(java.lang.Object item)
boolean
isLeaves()
Tests if both elements of the pair are leaf nodes
-
-
-
Field Detail
-
boundable1
private Boundable boundable1
-
boundable2
private Boundable boundable2
-
distance
private double distance
-
itemDistance
private ItemDistance itemDistance
-
-
Constructor Detail
-
BoundablePair
public BoundablePair(Boundable boundable1, Boundable boundable2, ItemDistance itemDistance)
-
-
Method Detail
-
getBoundable
public Boundable getBoundable(int i)
Gets one of the memberBoundable
s in the pair (indexed by [0, 1]).- Parameters:
i
- the index of the member to return (0 or 1)- Returns:
- the chosen member
-
distance
private double distance()
Computes the distance between theBoundable
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#itemDistance(ItemBoundable, ItemBoundable)
.- Returns:
-
getDistance
public double getDistance()
Gets the minimum possible distance between the Boundables in this pair. If the members are both items, this will be the exact distance between them. Otherwise, this distance will be a lower bound on the distances between the items in the members.- Returns:
- the exact or lower bound distance for this pair
-
compareTo
public int compareTo(java.lang.Object o)
Compares two pairs based on their minimum distances- Specified by:
compareTo
in interfacejava.lang.Comparable
-
isLeaves
public boolean isLeaves()
Tests if both elements of the pair are leaf nodes- Returns:
- true if both pair elements are leaf nodes
-
isComposite
public static boolean isComposite(java.lang.Object item)
-
area
private static double area(Boundable b)
-
expandToQueue
public void expandToQueue(PriorityQueue priQ, double minDistance)
For a pair which is not a leaf (i.e. has at least one composite boundable) computes a list of new pairs from the expansion of the larger boundable.
-
expand
private void expand(Boundable bndComposite, Boundable bndOther, PriorityQueue priQ, double minDistance)
-
-