com.vividsolutions.jts.geom
Class CoordinateSequenceComparator
java.lang.Object
com.vividsolutions.jts.geom.CoordinateSequenceComparator
- Comparator
public class CoordinateSequenceComparator
extends java.lang.Object
implements Comparator
Compares two
CoordinateSequence
s.
For sequences of the same dimension, the ordering is lexicographic.
Otherwise, lower dimensions are sorted before higher.
The dimensions compared can be limited; if this is done
ordinate dimensions above the limit will not be compared.
If different behaviour is required for comparing size, dimension, or
coordinate values, any or all methods can be overridden.
dimensionLimit
protected int dimensionLimit
The number of dimensions to test
CoordinateSequenceComparator
public CoordinateSequenceComparator()
Creates a comparator which will test all dimensions.
CoordinateSequenceComparator
public CoordinateSequenceComparator(int dimensionLimit)
Creates a comparator which will test only the specified number of dimensions.
dimensionLimit
- the number of dimensions to test
compare
public int compare(Object o1,
Object o2)
- -1, 0, or 1 depending on whether o1 is less than, equal to, or greater than o2
compare
public static int compare(double a,
double b)
Compare two double
s, allowing for NaN values.
NaN is treated as being less than any valid number.
- -1, 0, or 1 depending on whether a is less than, equal to or greater than b
compareCoordinate
protected int compareCoordinate(CoordinateSequence s1,
CoordinateSequence s2,
int i,
int dimension)
Compares the same coordinate of two
CoordinateSequence
s
along the given number of dimensions.
- -1, 0, or 1 depending on whether s1[i] is less than, equal to, or greater than s2[i]