@Before public void setUp() throws Exception { Assume.assumeTrue(GdalTestUtil.isGdalAvailable()); gdal = new GdalWrapper(GdalTestUtil.getGdalTranslate(), GdalTestUtil.getGdalData()); }
public static String getGdalTranslate() { if (isGdalAvailable()) return GDAL_TRANSLATE; else return null; }
public static void checkZippedGridData(InputStream input) throws Exception { try (ZipInputStream zis = new ZipInputStream(input)) { // unzip the result // check contents boolean gridFileFound = false, auxFileFound = false, prjFileFound = false; ZipEntry entry = null; while ((entry = zis.getNextEntry()) != null) { if (entry.getName().matches("^\\w+.asc.aux.xml$")) { auxFileFound = true; // } else if ("tazdem.prj".equals(entry.getName())) { } else if (entry.getName().matches("^\\w+.prj$")) { prjFileFound = true; // check projection checkGridProjection(zis); // } else if ("tazdem.asc".equals(entry.getName())) { } else if (entry.getName().matches("^\\w+.asc$")) { gridFileFound = true; // check grid content checkGridContent(zis); } } assertTrue(gridFileFound); assertTrue(auxFileFound); assertTrue(prjFileFound); } }
@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(); } } }
public static Map<String, String> getGdalData() { if (isGdalAvailable()) return Collections.singletonMap("GDAL_DATA", GDAL_DATA); else return Collections.emptyMap(); }
@Test public void testGetCoverageArcInfoGrid() throws Exception { assumeTrue(isFormatSupported("application/zip")); MockHttpServletResponse response = getAsServletResponse( "wcs?request=GetCoverage&service=WCS&version=2.0.1" + "&coverageId=DEM&Format=GDAL-ArcInfoGrid"); // assertEquals("application/zip", response.getContentType()); assertEquals("GDAL-ArcInfoGrid", response.getContentType()); GdalTestUtil.checkZippedGridData(getBinaryInputStream(response)); }
@Test public void testGetCoverageXyzGrid() throws Exception { assumeTrue(isFormatSupported("text/plain")); MockHttpServletResponse response = getAsServletResponse( "wcs?request=GetCoverage&service=WCS&version=2.0.1" + "&coverageId=DEM&Format=GDAL-XYZ"); // assertEquals("text/plain", response.getContentType()); assertEquals("GDAL-XYZ", response.getContentType()); GdalTestUtil.checkXyzData(getBinaryInputStream(response)); } }
@Before public void setup() { assumeTrue(GdalTestUtil.isGdalAvailable()); GdalConfigurator.DEFAULT.setExecutable(GdalTestUtil.getGdalTranslate()); GdalConfigurator.DEFAULT.setEnvironment(GdalTestUtil.getGdalData()); // force reload of the config, some tests may alter it GdalConfigurator configurator = applicationContext.getBean(GdalConfigurator.class); configurator.loadConfiguration(); }
@Before public void setUp() throws Exception { Assume.assumeTrue(GdalTestUtil.isGdalAvailable()); GdalConfigurator.DEFAULT.setExecutable(GdalTestUtil.getGdalTranslate()); GdalConfigurator.DEFAULT.setEnvironment(GdalTestUtil.getGdalData()); // force reload of the config, some tests may alter it GdalConfigurator configurator = applicationContext.getBean(GdalConfigurator.class); configurator.loadConfiguration(); }
@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()); }