* @param elevationDimension
* @return
* @throws IOException
*/
private NumberRange extractElevationSubset() throws IOException {
NumberRange elevationSubset = null;
if (elevationDimension != null) {
for (DimensionSubsetType dim : request.getDimensionSubset()) {
String dimension = WCSDimensionsSubsetHelper.getDimensionName(dim);
// only care for elevation dimensions
if (!WCSDimensionsSubsetHelper.ELEVATION_NAMES.contains(dimension.toLowerCase())) {
continue;
}
// did we parse the range already?
if (elevationSubset != null) {
throw new WCS20Exception("Elevation dimension trimming/slicing specified twice in the request",
WCS20Exception.WCS20ExceptionCode.InvalidSubsetting, "subset");
}
// now decide what to do
if (dim instanceof DimensionTrimType) {
// TRIMMING
final DimensionTrimType trim = (DimensionTrimType) dim;
final Double low = PARSER.parseDouble(trim.getTrimLow());
final Double high = PARSER.parseDouble(trim.getTrimHigh());
// low > high???
if (low > high) {
throw new WCS20Exception("Low greater than High: " + trim.getTrimLow()
+ ", " + trim.getTrimHigh(),
WCS20Exception.WCS20ExceptionCode.InvalidSubsetting, "subset");
}
elevationSubset = new NumberRange<Double>(Double.class, low, high);
} else if (dim instanceof DimensionSliceType) {
// SLICING
final DimensionSliceType slicing = (DimensionSliceType) dim;
final String slicePointS = slicing.getSlicePoint();
final Double slicePoint = PARSER.parseDouble(slicePointS);
elevationSubset = new NumberRange<Double>(Double.class, slicePoint, slicePoint);
} else {
throw new WCS20Exception(
"Invalid element found while attempting to parse dimension subsetting request: " + dim.getClass()
.toString(), WCS20Exception.WCS20ExceptionCode.InvalidSubsetting, "subset");
}
}
// right now we don't support trimming
// TODO: revisit when we have some multidimensional output support
if (!(reader instanceof StructuredGridCoverage2DReader) && elevationSubset != null && !elevationSubset.getMinValue().equals(elevationSubset.getMaxValue())) {
throw new WCS20Exception("Trimming on elevation is not supported at the moment on not StructuredGridCoverage2DReaders, only slicing is");
}
// apply nearest neighbor matching on elevation
if (elevationSubset != null && elevationSubset.getMinValue().equals(elevationSubset.getMaxValue())) {
interpolateElevation (elevationSubset, accessor);
}
}
return elevationSubset;
}