Package org.meteoinfo.jts.geom
Class CoordinateSequenceComparator
- java.lang.Object
-
- org.meteoinfo.jts.geom.CoordinateSequenceComparator
-
- All Implemented Interfaces:
java.util.Comparator
public class CoordinateSequenceComparator extends java.lang.Object implements java.util.ComparatorCompares twoCoordinateSequences. 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 Modifier and Type Field Description protected intdimensionLimitThe number of dimensions to test
-
Constructor Summary
Constructors Constructor Description CoordinateSequenceComparator()Creates a comparator which will test all dimensions.CoordinateSequenceComparator(int dimensionLimit)Creates a comparator which will test only the specified number of dimensions.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intcompare(double a, double b)Compare twodoubles, allowing for NaN values.intcompare(java.lang.Object o1, java.lang.Object o2)Compares twoCoordinateSequences for relative order.protected intcompareCoordinate(CoordinateSequence s1, CoordinateSequence s2, int i, int dimension)Compares the same coordinate of twoCoordinateSequences along the given number of dimensions.
-
-
-
Constructor Detail
-
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 Detail
-
compare
public static int compare(double a, double b)Compare twodoubles, allowing for NaN values. NaN is treated as being less than any valid number.- Parameters:
a- adoubleb- adouble- Returns:
- -1, 0, or 1 depending on whether a is less than, equal to or greater than b
-
compare
public int compare(java.lang.Object o1, java.lang.Object o2)Compares twoCoordinateSequences for relative order.- Specified by:
comparein interfacejava.util.Comparator- Parameters:
o1- aCoordinateSequenceo2- aCoordinateSequence- Returns:
- -1, 0, or 1 depending on whether o1 is less than, equal to, or greater than o2
-
compareCoordinate
protected int compareCoordinate(CoordinateSequence s1, CoordinateSequence s2, int i, int dimension)
Compares the same coordinate of twoCoordinateSequences along the given number of dimensions.- Parameters:
s1- aCoordinateSequences2- aCoordinateSequencei- the index of the coordinate to testdimension- the number of dimensiosn to test- Returns:
- -1, 0, or 1 depending on whether s1[i] is less than, equal to, or greater than s2[i]
-
-