final String outputFormat = request.getOutputFormat();
delegate = CoverageResponseDelegateFactory.encoderFor(outputFormat);
if(delegate == null)
throw new WcsException("Output format: " + outputFormat + " not supported by geoserver " +
"for this Coverage", WcsExceptionCode.InvalidParameterValue, "format");
final Catalog catalog = request.getWCS().getGeoServer().getCatalog();
CoverageInfo meta = null;
GridCoverage coverage = null;
try {
meta = catalog.getCoverageByName(request.getCoverage());
if (!meta.getSupportedFormats().contains(outputFormat.toUpperCase())) {
WcsException newEx = new WcsException(new StringBuffer("output format: ").append(
outputFormat).append(" not ")
.append("supported by geoserver for this Coverage")
.toString());
throw newEx;
}
final Format format = meta.getStore().getFormat();
final AbstractGridCoverage2DReader reader =
(AbstractGridCoverage2DReader) catalog.getResourcePool().getGridCoverageReader(meta.getStore(),hints);
// /////////////////////////////////////////////////////////
//
// Setting coverage reading params.
//
// /////////////////////////////////////////////////////////
final ParameterValueGroup params = reader.getFormat().getReadParameters();
final GridCoverage2D finalCoverage = getFinalCoverage(request, meta, reader,
CoverageUtils.getParametersKVP(params));
delegate.prepare(outputFormat, finalCoverage);
} catch (IOException e) {
final WcsException newEx = new WcsException(e, "problem with CoverageResults",
request.getHandle());
throw newEx;
} catch (NoSuchElementException e) {
final WcsException newEx = new WcsException(e, "problem with CoverageResults",
request.getHandle());
throw newEx;
} catch (IllegalArgumentException e) {
final WcsException newEx = new WcsException(e, "problem with CoverageResults",
request.getHandle());
throw newEx;
} catch (SecurityException e) {
final WcsException newEx = new WcsException(e, "problem with CoverageResults",
request.getHandle());
throw newEx;
} catch (WcsException e) {
final WcsException newEx = new WcsException(e, "problem with CoverageResults",
request.getHandle());
throw newEx;
} catch (FactoryException e) {
final WcsException newEx = new WcsException(e, "problem with CoverageResults",
request.getHandle());
throw newEx;
} catch (IndexOutOfBoundsException e) {
final WcsException newEx = new WcsException(e, "problem with CoverageResults",
request.getHandle());
throw newEx;
} catch (TransformException e) {
final WcsException newEx = new WcsException(e, "problem with CoverageResults",
request.getHandle());
throw newEx;
}
}