@Override public void write(Object value, OutputStream output, Operation operation) throws IOException, ServiceException { GridCoverage[] coverages = (GridCoverage[]) value; // grab the delegate for coverage encoding GetCoverageType request = (GetCoverageType) operation.getParameters()[0]; String outputFormat = request.getOutput().getFormat().getValue(); CoverageResponseDelegate delegate = getResponseDelegate(outputFormat); // grab the coverage info for Coverages document encoding final GridCoverage2D coverage = (GridCoverage2D) coverages[0]; // ImageIOUtilities.visualize(coverage.getRenderedImage()); // write the coverage try { delegate.encode(coverage, outputFormat, Collections.EMPTY_MAP, output); output.flush(); } finally { // if(output != null) output.close(); } } }
@Override public String getMimeType(Object value, Operation operation) throws ServiceException { if (!(operation.getParameters()[0] instanceof GetCoverageType)) throw new WcsException( "Cannot handle object of type: " + operation.getParameters()[0].getClass()); GetCoverageType getCoverage = (GetCoverageType) operation.getParameters()[0]; String outputFormat = getCoverage.getOutput().getFormat().getValue(); CoverageResponseDelegate delegate = getResponseDelegate(outputFormat); return delegate.getMimeType(outputFormat); }
@Override public boolean canHandle(Operation operation) { if (!(operation.getParameters()[0] instanceof GetCoverageType)) return false; GetCoverageType getCoverage = (GetCoverageType) operation.getParameters()[0]; String outputFormat = getCoverage.getOutput().getFormat().getValue(); CoverageResponseDelegate delegate = getResponseDelegate(outputFormat); return delegate.canProduce(outputFormat); }
@Override public String getAttachmentFileName(Object value, Operation operation) { if (!(operation.getParameters()[0] instanceof GetCoverageType)) throw new WcsException( "Cannot handle object of type: " + operation.getParameters()[0].getClass()); GetCoverageType getCoverage = (GetCoverageType) operation.getParameters()[0]; String outputFormat = getCoverage.getOutput().getFormat().getValue(); CoverageResponseDelegate delegate = getResponseDelegate(outputFormat); return getCoverage.getSourceCoverage() + "." + delegate.getFileExtension(outputFormat); }
public void testBasic() throws Exception { Map<String, Object> raw = baseMap(); final String layerId = getLayerId(TASMANIA_BM); raw.put("SourceCoverage", layerId); raw.put("version", "1.0.0"); raw.put("format", "image/tiff"); raw.put("BBOX", "-45,146,-42,147"); raw.put("CRS", "EPSG:4326"); raw.put("width", "150"); raw.put("height", "150"); GetCoverageType getCoverage = (GetCoverageType) reader.read(reader.createRequest(), parseKvp(raw), raw); assertEquals(layerId, getCoverage.getSourceCoverage()); assertEquals("image/tiff", getCoverage.getOutput().getFormat().getValue()); assertEquals("EPSG:4326", getCoverage.getOutput().getCrs().getValue()); }
@Test public void testBasic() throws Exception { Map<String, Object> raw = baseMap(); final String layerId = getLayerId(TASMANIA_BM); raw.put("SourceCoverage", layerId); raw.put("version", "1.0.0"); raw.put("format", "image/tiff"); raw.put("BBOX", "-45,146,-42,147"); raw.put("CRS", "EPSG:4326"); raw.put("width", "150"); raw.put("height", "150"); GetCoverageType getCoverage = (GetCoverageType) reader.read(reader.createRequest(), parseKvp(raw), raw); assertEquals(layerId, getCoverage.getSourceCoverage()); assertEquals("image/tiff", getCoverage.getOutput().getFormat().getValue()); assertEquals("EPSG:4326", getCoverage.getOutput().getCrs().getValue()); }
assertEquals("image/tiff", getCoverage.getOutput().getFormat().getValue()); assertEquals("nearest neighbor", getCoverage.getInterpolationMethod().toString()); assertEquals("image/tiff", getCoverage.getOutput().getFormat().getValue()); assertEquals("bilinear", getCoverage.getInterpolationMethod().toString()); assertEquals("image/tiff", getCoverage.getOutput().getFormat().getValue()); assertEquals("nearest neighbor", getCoverage.getInterpolationMethod().toString()); assertEquals("image/tiff", getCoverage.getOutput().getFormat().getValue());
(GetCoverageType) reader.read(reader.createRequest(), parseKvp(raw), raw); assertEquals(layerId, getCoverage.getSourceCoverage()); assertEquals("image/tiff", getCoverage.getOutput().getFormat().getValue()); assertEquals("nearest neighbor", getCoverage.getInterpolationMethod().toString()); assertEquals("image/tiff", getCoverage.getOutput().getFormat().getValue()); assertEquals("bilinear", getCoverage.getInterpolationMethod().toString()); assertEquals("image/tiff", getCoverage.getOutput().getFormat().getValue()); assertEquals("nearest neighbor", getCoverage.getInterpolationMethod().toString()); assertEquals("image/tiff", getCoverage.getOutput().getFormat().getValue()); assertEquals("bicubic", getCoverage.getInterpolationMethod().toString());
assertEquals(370725.976428591, envelope.getUpperCorner().getOrdinate(0)); assertEquals(5196961.352859256, envelope.getUpperCorner().getOrdinate(1)); assertNotNull(gc.getOutput().getCrs()); assertEquals("EPSG:4326", gc.getOutput().getCrs().getValue()); assertNotNull(gc.getOutput().getFormat()); assertEquals("TIFF", gc.getOutput().getFormat().getValue());
assertEquals(370725.976428591, envelope.getUpperCorner().getOrdinate(0), 0); assertEquals(5196961.352859256, envelope.getUpperCorner().getOrdinate(1), 0); assertNotNull(gc.getOutput().getCrs()); assertEquals("EPSG:4326", gc.getOutput().getCrs().getValue()); assertNotNull(gc.getOutput().getFormat()); assertEquals("TIFF", gc.getOutput().getFormat().getValue());