@Override public void encode(Object value, OutputStream os) throws Exception { delegate.encode((GridCoverage2D) value, outputFormat, null, os); }
protected GdalCDataPPIO( String outputFormat, GdalCoverageResponseDelegate delegate, String mimeType) { super(GridCoverage2D.class, GridCoverage2D.class, mimeType); this.delegate = delegate; this.outputFormat = outputFormat; this.fileExtension = delegate.getFileExtension(outputFormat); }
@Test public void testContentTypeText() { assertEquals("text/plain", gdalCovRespDelegate.getMimeType("GDAL-XYZ")); assertEquals("txt", gdalCovRespDelegate.getFileExtension("GDAL-XYZ")); }
@Override public List<ProcessParameterIO> getProcessParameterIO() { List<ProcessParameterIO> gdalParams = new ArrayList<ProcessParameterIO>(); for (Format of : this.delegate.getFormats()) { ProcessParameterIO ppio = null; String computedMimeType = delegate.getMimeType(of.getGeoserverFormat()); if (of.getGeoserverFormat() != null && !of.getGeoserverFormat().isEmpty()) { computedMimeType = computedMimeType + "; subtype=" + of.getGeoserverFormat();
@Before public void setUp() throws Exception { // check if we can run the tests Assume.assumeTrue(GdalTestUtil.isGdalAvailable()); // the coverage response delegate gdalCovRespDelegate = new GdalCoverageResponseDelegate(new GeoServerImpl(), new GdalWrapperFactory()); // add default formats for (Format format : GdalConfigurator.DEFAULT.getFormats()) { gdalCovRespDelegate.addFormat(format); } gdalCovRespDelegate.setExecutable(GdalTestUtil.getGdalTranslate()); gdalCovRespDelegate.setEnvironment(GdalTestUtil.getGdalData()); }
@Test public void testCanProduce() { assertTrue(gdalCovRespDelegate.canProduce("GDAL-JPEG2000")); assertTrue(gdalCovRespDelegate.canProduce("GDAL-XYZ")); // not among default formats assertFalse(gdalCovRespDelegate.canProduce("GDAL-MrSID")); }
@Test public void testContentTypePDF() { assertEquals("application/pdf", gdalCovRespDelegate.getMimeType("GDAL-PDF")); assertEquals("pdf", gdalCovRespDelegate.getFileExtension("GDAL-PDF")); }
@Test public void testDescribeProcess() throws Exception { GdalCoverageResponseDelegate delegate = applicationContext.getBean(GdalCoverageResponseDelegate.class); Document d = getAsDOM(root() + "service=wps&request=describeprocess&identifier=gs:CropCoverage"); String base = "/wps:ProcessDescriptions/ProcessDescription/ProcessOutputs"; for (Format f : delegate.getFormats()) { assertXpathExists( base + "/Output[1]/ComplexOutput/Supported/Format[MimeType='" + delegate.getMimeType(f.getGeoserverFormat()) + "; subtype=" + f.getGeoserverFormat() + "']", d); } }
@Test public void testContentTypeZip() { assertEquals("application/zip", gdalCovRespDelegate.getMimeType("GDAL-ArcInfoGrid")); assertEquals("zip", gdalCovRespDelegate.getFileExtension("GDAL-ArcInfoGrid")); }
@Override public void encode(Object value, OutputStream os) throws Exception { delegate.encode((GridCoverage2D) value, outputFormat, null, os); }
protected GdalXMLPPIO(String outputFormat, GdalCoverageResponseDelegate delegate) { super(GridCoverage2D.class, GridCoverage2D.class, GML.RectifiedGridType); this.delegate = delegate; this.outputFormat = outputFormat; this.fileExtension = delegate.getFileExtension(outputFormat); }
@Test public void testContentTypeJP2K() { assertEquals("image/jp2", gdalCovRespDelegate.getMimeType("GDAL-JPEG2000")); assertEquals("jp2", gdalCovRespDelegate.getFileExtension("GDAL-JPEG2000")); }
@Override public void encode(Object value, OutputStream os) throws Exception { delegate.encode((GridCoverage2D) value, outputFormat, null, os); }
protected GdalBinaryPPIO( String outputFormat, GdalCoverageResponseDelegate delegate, String mimeType) { super(GridCoverage2D.class, GridCoverage2D.class, mimeType); this.delegate = delegate; this.outputFormat = outputFormat; this.fileExtension = delegate.getFileExtension(outputFormat); }
@Test public void testZippedGrid() throws Exception { // prepare input File tempFile = prepareInput(); try { GridCoverage2DReader covReader = new GeoTiffReader(tempFile); GridCoverage2D cov = covReader.read(null); try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { // write out gdalCovRespDelegate.encode(cov, "GDAL-ArcInfoGrid", null, bos); GdalTestUtil.checkZippedGridData(new ByteArrayInputStream(bos.toByteArray())); } } finally { if (tempFile != null) { tempFile.delete(); } } }
@Test public void testXYZ() throws Exception { // prepare input File tempFile = prepareInput(); try { GridCoverage2DReader covReader = new GeoTiffReader(tempFile); GridCoverage2D cov = covReader.read(null); try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { // write out gdalCovRespDelegate.encode(cov, "GDAL-XYZ", null, bos); // parse the text output to check it's really XYZ data try (InputStream is = new ByteArrayInputStream(bos.toByteArray())) { GdalTestUtil.checkXyzData(is); } } } finally { if (tempFile != null) { tempFile.delete(); } } }