@Test public void testReader() throws IllegalArgumentException, IOException, NoSuchAuthorityCodeException, CQLException { final File file = TestData.file(this, "sample"); final String string = "PATH='folder1/world.tif'"; Filter filter = CQL.toFilter(string); final ImageCollectionReader reader = new ImageCollectionReader(file); final ParameterValue<GridGeometry2D> gg = AbstractGridFormat.READ_GRIDGEOMETRY2D.createValue(); final GeneralEnvelope envelope = new GeneralEnvelope(new Rectangle(1000,-800,1000,400)); envelope.setCoordinateReferenceSystem(CartesianAuthorityFactory.GENERIC_2D); final Rectangle rasterArea = new Rectangle(0, 0, 500, 200); final GridEnvelope2D range= new GridEnvelope2D(rasterArea); gg.setValue(new GridGeometry2D(range, envelope)); final ParameterValue<Filter> ff = ImageCollectionFormat.FILTER.createValue(); ff.setValue(filter); final ParameterValue<double[]> background = ImageCollectionFormat.BACKGROUND_VALUES.createValue(); background.setValue(new double[]{0}); GeneralParameterValue[] params = new GeneralParameterValue[] {ff, gg, background}; if (reader != null) { GridCoverage2D coverage = (GridCoverage2D) reader.read(params); RenderedImage image = coverage.getRenderedImage(); assertTrue(image.getWidth() == 500); assertTrue(image.getHeight() == 200); } }
@Override public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Reading image from " + sourceURL.toString() + "\nHighest res " + highestRes[0] + " " + highestRes[1]); } final Collection<GridCoverage2D> response = rasterManager.read(params); if (response.isEmpty()){ if (LOGGER.isLoggable(Level.FINE)){ LOGGER.fine("The response is empty. ==> returning a null GridCoverage"); } return null; } else return response.iterator().next(); }
ImageCollectionReader extends AbstractGridCoverage2DReader implements GridCoverageReader { @Override public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Reading image from " + sourceURL.toString() + "\nHighest res " + highestRes[0] + " " + highestRes[1]); } final Collection<GridCoverage2D> response = rasterManager.read(params); if (response.isEmpty()){ if (LOGGER.isLoggable(Level.FINE)){ LOGGER.fine("The response is empty. ==> returning a null GridCoverage"); } return null; } else return response.iterator().next(); } }
ImageCollectionReader extends AbstractGridCoverage2DReader implements GridCoverageReader { @Override public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Reading image from " + sourceURL.toString() + "\nHighest res " + highestRes[0] + " " + highestRes[1]); } final Collection<GridCoverage2D> response = rasterManager.read(params); if (response.isEmpty()){ if (LOGGER.isLoggable(Level.FINE)){ LOGGER.fine("The response is empty. ==> returning a null GridCoverage"); } return null; } else return response.iterator().next(); } ImageCollectionReader(Object input);  ImageCollectionReader(Object input, Hints uHints); }
ImageCollectionReader extends AbstractGridCoverage2DReader implements GridCoverageReader { @Override public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Reading image from " + sourceURL.toString() + "\nHighest res " + highestRes[0] + " " + highestRes[1]); } final Collection<GridCoverage2D> response = rasterManager.read(params); if (response.isEmpty()){ if (LOGGER.isLoggable(Level.FINE)){ LOGGER.fine("The response is empty. ==> returning a null GridCoverage"); } return null; } else return response.iterator().next(); } ImageCollectionReader(Object input);  ImageCollectionReader(Object input, Hints uHints); @Override int getGridCoverageCount(); @Override void dispose(); Format getFormat(); @Override GridCoverage2D read(GeneralParameterValue[] params); }
ImageCollectionReader extends AbstractGridCoverage2DReader implements GridCoverageReader { @Override public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Reading image from " + sourceURL.toString() + "\nHighest res " + highestRes[0] + " " + highestRes[1]); } final Collection<GridCoverage2D> response = rasterManager.read(params); if (response.isEmpty()){ if (LOGGER.isLoggable(Level.FINE)){ LOGGER.fine("The response is empty. ==> returning a null GridCoverage"); } return null; } else return response.iterator().next(); } ImageCollectionReader(Object input);  ImageCollectionReader(Object input, Hints uHints); @Override int getGridCoverageCount(); @Override void dispose(); Format getFormat(); @Override GridCoverage2D read(GeneralParameterValue[] params);  }