zMinMax static method
Determine the min and max "z" values in an array of Coordinates.
@param cs The array to search.
@param target array with at least two elements where to hold the min and max zvalues.
target0
will be filled with the minimum zvalue, target1
with the maximum. The array
current values, if not NaN, will be taken into acount in the computation.
Implementation
static void zMinMax(final CoordinateSequence cs, List<double> target) {
if (cs.getDimension() < 3) {
return;
}
double zmin;
double zmax;
bool validZFound = false;
zmin = double.nan;
zmax = double.nan;
double z;
final int size = cs.size();
for (int t = size - 1; t >= 0; t--) {
z = cs.getOrdinate(t, 2);
if (!(z.isNaN)) {
if (validZFound) {
if (z < zmin) {
zmin = z;
}
if (z > zmax) {
zmax = z;
}
} else {
validZFound = true;
zmin = z;
zmax = z;
}
}
}
if (!zmin.isNaN) {
target[0] = zmin;
}
if (!zmax.isNaN) {
target[1] = (zmax);
}
}