isEqual static method
Tests whether two {@link CoordinateSequence}s are equal.
To be equal, the sequences must be the same length.
They do not need to be of the same dimension,
but the ordinate values for the smallest dimension of the two
must be equal.
Two NaN
ordinates values are considered to be equal.
@param cs1 a CoordinateSequence @param cs2 a CoordinateSequence @return true if the sequences are equal in the common dimensions
Implementation
static bool isEqual(CoordinateSequence cs1, CoordinateSequence cs2) {
int cs1Size = cs1.size();
int cs2Size = cs2.size();
if (cs1Size != cs2Size) return false;
int dim = math.min(cs1.getDimension(), cs2.getDimension());
for (int i = 0; i < cs1Size; i++) {
for (int d = 0; d < dim; d++) {
double v1 = cs1.getOrdinate(i, d);
double v2 = cs2.getOrdinate(i, d);
if (cs1.getOrdinate(i, d) == cs2.getOrdinate(i, d)) continue;
// special check for NaNs
if (v1.isNaN && v2.isNaN) continue;
return false;
}
}
return true;
}