/** * Parses teh TIFF contained in the response as a {@link RenderedImage} * @param response * @return * @throws IOException */ RenderedImage readTiff(MockHttpServletResponse response) throws IOException { ImageReader reader = ImageIO.getImageReadersByFormatName("tiff").next(); reader.setInput(ImageIO.createImageInputStream(getBinaryInputStream(response))); return reader.read(0); }
/** * Parses teh TIFF contained in the response as a {@link RenderedImage} * * @param response * @throws IOException */ RenderedImage readTiff(MockHttpServletResponse response) throws IOException { ImageReader reader = ImageIO.getImageReadersByFormatName("tiff").next(); reader.setInput(ImageIO.createImageInputStream(getBinaryInputStream(response))); return reader.read(0); }
private void checkPixelValue(MockHttpServletResponse response, int x, int y, double value) throws IOException, FileNotFoundException, DataSourceException { // save File tiffFile = File.createTempFile("wcs", "", new File("target")); try { IOUtils.copy(getBinaryInputStream(response), new FileOutputStream(tiffFile)); // make sure we can read the coverage back GeoTiffReader reader = new GeoTiffReader(tiffFile); GridCoverage2D result = reader.read(null); // check a pixel double[] pixel = new double[1]; result.getRenderedImage().getData().getPixel(x, y, pixel); assertEquals(value, pixel[0], 1e-6); } finally { tiffFile.delete(); } }
private void checkTimeCurrent(MockHttpServletResponse response) throws IOException, FileNotFoundException, DataSourceException { // save File tiffFile = File.createTempFile("wcs", "", new File("target")); IOUtils.copy(getBinaryInputStream(response), new FileOutputStream(tiffFile)); // make sure we can read the coverage back GeoTiffReader reader = new GeoTiffReader(tiffFile); GridCoverage2D result = reader.read(null); /* gdallocationinfo NCOM_wattemp_000_20081101T0000000_12.tiff 10 10 Report: Location: (10P,10L) Band 1: Value: 18.2849999185419 */ // check a pixel double[] pixel = new double[1]; result.getRenderedImage().getData().getPixel(10, 10, pixel); assertEquals(18.2849999185419, pixel[0], 1e-6); tiffFile.delete(); }
private void checkTimeFirst(MockHttpServletResponse response) throws IOException, FileNotFoundException, DataSourceException { // save File tiffFile = File.createTempFile("wcs", "", new File("target")); IOUtils.copy(getBinaryInputStream(response), new FileOutputStream(tiffFile)); // make sure we can read the coverage back GeoTiffReader reader = new GeoTiffReader(tiffFile); GridCoverage2D result = reader.read(null); /* gdallocationinfo NCOM_wattemp_000_20081031T0000000_12.tiff 10 10 Report: Location: (10P,10L) Band 1: Value: 18.2659999176394 */ // check a pixel double[] pixel = new double[1]; result.getRenderedImage().getData().getPixel(10, 10, pixel); assertEquals(18.2659999176394, pixel[0], 1e-6); tiffFile.delete(); }
public void testElevationSecond() throws Exception { String request = getWaterTempElevationRequest("100.0"); MockHttpServletResponse response = postAsServletResponse("wcs", request); assertEquals("image/tiff;subtype=\"geotiff\"", response.getContentType()); // save File tiffFile = File.createTempFile("wcs", "", new File("target")); IOUtils.copy(getBinaryInputStream(response), new FileOutputStream(tiffFile)); // make sure we can read the coverage back GeoTiffReader reader = new GeoTiffReader(tiffFile); GridCoverage2D result = reader.read(null); /* gdallocationinfo NCOM_wattemp_100_20081101T0000000_12.tiff 10 10 Report: Location: (10P,10L) Band 1: Value: 13.337999683572 */ // check a pixel double[] pixel = new double[1]; result.getRenderedImage().getData().getPixel(10, 10, pixel); assertEquals(13.337999683572, pixel[0], 1e-6); tiffFile.delete(); }
AbstractGridCoverage2DReader reader = format.getReader(getBinaryInputStream(response));
GridCoverage2DReader reader = format.getReader(getBinaryInputStream(response));