final GeneralEnvelope requestedEnvelope = (GeneralEnvelope) envelopes.get(0);
final OutputType output = request.getOutput();
if (output == null)
throw new IllegalArgumentException("Output type was null");
final CodeType outputCRS = output.getCrs();
final int dimension = grid.getDimension().intValue();
// WE SUPPORT 3D DIMENSION ONLY VIA A BAND
if (dimension == 3)
throw new WcsException(
"We support a third dimension only via a specifica Axis in Range",
InvalidParameterValue, null);
//
// GRAB A READER
//
// grab the reader using the default params
final AbstractGridCoverage2DReader reader = (AbstractGridCoverage2DReader) meta
.getGridCoverageReader(null, WCSUtils.getReaderHints(wcs));
if (reader == null) {
// cannot instantiate a reader, we should return an empty array
return coverageResults.toArray(new GridCoverage2D[] {});
}
// get native elements and then play with the the requested ones
final GeneralEnvelope nativeEnvelope = reader.getOriginalEnvelope();
final CoordinateReferenceSystem nativeCRS = nativeEnvelope
.getCoordinateReferenceSystem();
// get requested crs
String requestedCRS = null;
if (outputCRS != null) {
requestedCRS = outputCRS.getValue();
}
// Compute the target crs, the crs that the final coverage will be served into
final CoordinateReferenceSystem targetCRS;
if (requestedCRS == null) {