@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(); } } }
private OutputType parseOutputElement(final Map<String, String> kvp) throws Exception { final OutputType output = Wcs10Factory.eINSTANCE.createOutputType(); final CodeType crsType = Gml4wcsFactory.eINSTANCE.createCodeType(); final CodeType formatType = Gml4wcsFactory.eINSTANCE.createCodeType(); // check and set format String format = (String) kvp.get("format"); if (format == null) throw new WcsException( "format parameter is mandatory", MissingParameterValue, "format"); final String crsName = (String) (kvp.get("response_crs") != null ? kvp.get("response_crs") : kvp.get("crs")); CoordinateReferenceSystem crs = null; if (crsName != null) { crs = decodeCRS100(crsName); crsType.setValue(CRS.lookupIdentifier(crs, true)); output.setCrs(crsType); } formatType.setValue(format); output.setFormat(formatType); return output; }
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()); }
final CodeType outputCRS = output.getCrs();
@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(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());
@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); }
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());
@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); }
/** * Checks that the elements of the Output part of the request do make sense by comparing them to * the coverage metadata * * @param info * @param rangeSubset */ private void checkOutput(CoverageInfo meta, OutputType output) { if (output == null) return; // check output format String format = output.getFormat().getValue(); String declaredFormat = getDeclaredFormat(meta.getSupportedFormats(), format); if (declaredFormat == null) throw new WcsException( "format " + format + " is not supported for this coverage", InvalidParameterValue, "format"); // check requested CRS // if (output.getCrs() != null) { // String requestedCRS = output.getCrs().getValue(); // if (getRequestResponseCRS(meta.getRequestCRSs(), requestedCRS) == null && // getRequestResponseCRS(meta.getResponseCRSs(), requestedCRS) == null) // throw new WcsException("CRS " + requestedCRS + " is not supported for this coverage", // InvalidParameterValue, "CRS"); // } else { // // The requested CRS was not specified ... what to do ??? // } }
@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); }
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());