byte[] tiffContents = getBinary(response);
File file = File.createTempFile("bm_gtiff", "bm_gtiff.tiff", new File("./target"));
FileUtils.writeByteArrayToFile(file, tiffContents);
// check we can read it as a TIFF and it is similare to the origina one
GeoTiffReader readerTarget = new GeoTiffReader(file);
GridCoverage2D targetCoverage = null, sourceCoverage=null;
try {
targetCoverage = readerTarget.read(null);
sourceCoverage=(GridCoverage2D) this.getCatalog().getCoverageByName("BlueMarble").getGridCoverageReader(null, null).read(null);
// checks
assertEquals(sourceCoverage.getCoordinateReferenceSystem(), targetCoverage.getCoordinateReferenceSystem());
assertEnvelopeEquals(sourceCoverage, targetCoverage);
assertEquals(sourceCoverage.getGridGeometry().getGridRange().getSpan(0)/2, targetCoverage.getGridGeometry().getGridRange().getSpan(0));
assertEquals(sourceCoverage.getGridGeometry().getGridRange().getSpan(1)/2, targetCoverage.getGridGeometry().getGridRange().getSpan(1));
} finally {
try{
readerTarget.dispose();
} catch (Exception e) {
LOGGER.log(Level.WARNING,e.getLocalizedMessage(),e);
}
try{
scheduleForCleaning(targetCoverage);
} catch (Exception e) {
LOGGER.log(Level.WARNING,e.getLocalizedMessage(),e);
}
try{
scheduleForCleaning(sourceCoverage);
} catch (Exception e) {
LOGGER.log(Level.WARNING,e.getLocalizedMessage(),e);
}
}
// upsample
response = getAsServletResponse("wcs?request=GetCoverage&service=WCS&version=2.0.1" +
"&coverageId=wcs__BlueMarble&&Format=image/tiff&SCALEFACTOR=2");
assertEquals("image/tiff", response.getContentType());
tiffContents = getBinary(response);
file = File.createTempFile("bm_gtiff", "bm_gtiff.tiff", new File("./target"));
FileUtils.writeByteArrayToFile(file, tiffContents);
// check we can read it as a TIFF and it is similare to the origina one
readerTarget = new GeoTiffReader(file);
try {
targetCoverage = readerTarget.read(null);
sourceCoverage=(GridCoverage2D) this.getCatalog().getCoverageByName("BlueMarble").getGridCoverageReader(null, null).read(null);
// checks
assertEquals(sourceCoverage.getCoordinateReferenceSystem(), targetCoverage.getCoordinateReferenceSystem());
assertEnvelopeEquals(sourceCoverage, targetCoverage);
assertEquals(sourceCoverage.getGridGeometry().getGridRange().getSpan(0)*2, targetCoverage.getGridGeometry().getGridRange().getSpan(0));
assertEquals(sourceCoverage.getGridGeometry().getGridRange().getSpan(1)*2, targetCoverage.getGridGeometry().getGridRange().getSpan(1));
} finally {
try{
readerTarget.dispose();
} catch (Exception e) {
LOGGER.log(Level.WARNING,e.getLocalizedMessage(),e);
}
try{
scheduleForCleaning(targetCoverage);