code: public static double[] zMinMax(final Coordinate[] cs) {
          double zmin;
          double zmax;
          boolean validZFound = false;
          double[] result = new double[2];
  
          zmin = Double.NaN;
          zmax = Double.NaN;
  
          double z;
  
          for (int t = cs.length - 1; t >= 0; t--) {
              z = cs[t].z;
  
              if (!(Double.isNaN(z))) {
                  if (validZFound) {
                      if (z < zmin) {
                          zmin = z;
                      }
  
                      if (z > zmax) {
                          zmax = z;
                      }
                  } else {
                      validZFound = true;
                      zmin = z;
                      zmax = z;
                  }
              }
          }
          result[0] = (zmin);
          result[1] = (zmax);
          return result;
      }
docs: Determine the min and max "z" values in an array of Coordinates.
  
  @param cs The array to search.
  @return An array of size 2, index 0 is min, index 1 is max.