Package org.locationtech.jts.geom
Class CoordinateSequenceComparator
java.lang.Object
org.locationtech.jts.geom.CoordinateSequenceComparator
- All Implemented Interfaces:
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.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a comparator which will test all dimensions.CoordinateSequenceComparator
(int dimensionLimit) Creates a comparator which will test only the specified number of dimensions. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
compare
(double a, double b) Compare twodouble
s, allowing for NaN values.int
Compares twoCoordinateSequence
s for relative order.protected int
compareCoordinate
(CoordinateSequence s1, CoordinateSequence s2, int i, int dimension) Compares the same coordinate of twoCoordinateSequence
s along the given number of dimensions.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
dimensionLimit
protected int dimensionLimitThe number of dimensions to test
-
-
Constructor Details
-
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.- Parameters:
dimensionLimit
- the number of dimensions to test
-
-
Method Details
-
compare
public static int compare(double a, double b) Compare twodouble
s, allowing for NaN values. NaN is treated as being less than any valid number.- Parameters:
a
- adouble
b
- adouble
- Returns:
- -1, 0, or 1 depending on whether a is less than, equal to or greater than b
-
compare
Compares twoCoordinateSequence
s for relative order.- Specified by:
compare
in interfaceComparator
- Parameters:
o1
- aCoordinateSequence
o2
- aCoordinateSequence
- Returns:
- -1, 0, or 1 depending on whether o1 is less than, equal to, or greater than o2
-
compareCoordinate
Compares the same coordinate of twoCoordinateSequence
s along the given number of dimensions.- Parameters:
s1
- aCoordinateSequence
s2
- aCoordinateSequence
i
- the index of the coordinate to testdimension
- the number of dimensions to test- Returns:
- -1, 0, or 1 depending on whether s1[i] is less than, equal to, or greater than s2[i]
-