@Test public void testExternalOverviews() throws Exception { final File file = TestData.file(GeoTiffReaderTest.class, "ovr.tif"); assertNotNull(file); assertEquals(true, file.exists()); GeoTiffReaderTester reader = new GeoTiffReaderTester(file); final int nOvrs = reader.getNumOverviews(); LOGGER.info("Number of external overviews: " + nOvrs); assertEquals(4, nOvrs); double[][] overviewResolutions = reader.getOverviewResolutions(); assertEquals(overviewResolutions.length, 4); final ParameterValue<GridGeometry2D> gg = AbstractGridFormat.READ_GRIDGEOMETRY2D.createValue(); final GeneralEnvelope envelope = reader.getOriginalEnvelope(); final Dimension dim = new Dimension(); dim.setSize(reader.getOriginalGridRange().getSpan(0) / 4.0, reader.getOriginalGridRange() .getSpan(1) / 4.0); final Rectangle rasterArea = ((GridEnvelope2D) reader.getOriginalGridRange()); rasterArea.setSize(dim); final GridEnvelope2D range = new GridEnvelope2D(rasterArea); gg.setValue(new GridGeometry2D(range, envelope)); GridCoverage2D coverage = reader.read(new GeneralParameterValue[] { gg }); RenderedImage image = coverage.getRenderedImage(); assertEquals(image.getWidth(), 90); assertEquals(image.getHeight(), 45); final double delta = 0.00001; assertEquals(overviewResolutions[0][0], 2.0, delta); assertEquals(overviewResolutions[0][1], 2.0, delta); assertEquals(overviewResolutions[1][0], 4.0, delta); assertEquals(overviewResolutions[1][1], 4.0, delta); assertEquals(overviewResolutions[2][0], 8, delta); assertEquals(overviewResolutions[2][1], 7.826086956, delta); assertEquals(overviewResolutions[3][0], 15.6521739, delta); assertEquals(overviewResolutions[3][1], 15, delta); }
@Override public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Reading image from " + sourceURL.toString() + "\n" + "Highest 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(); } }
GeoTiffReader extends AbstractGridCoverage2DReader implements
		GridCoverageReader { @Override public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Reading image from " + sourceURL.toString() + "\n" + "Highest 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(); } } }
GeoTiffReader extends AbstractGridCoverage2DReader implements
		GridCoverageReader { @Override public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Reading image from " + sourceURL.toString() + "\n" + "Highest 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(); } } GeoTiffReader(Object input);  GeoTiffReader(Object input, Hints uHints); }
GeoTiffReader extends AbstractGridCoverage2DReader implements
		GridCoverageReader { @Override public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Reading image from " + sourceURL.toString() + "\n" + "Highest 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(); } } GeoTiffReader(Object input);  GeoTiffReader(Object input, Hints uHints); @Override int getGridCoverageCount(); @Override void dispose(); Format getFormat(); @Override GridCoverage2D read(GeneralParameterValue[] params); GeoTiffIIOMetadataDecoder getMetadata(); }
GeoTiffReader extends AbstractGridCoverage2DReader implements
		GridCoverageReader { @Override public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Reading image from " + sourceURL.toString() + "\n" + "Highest 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(); } } GeoTiffReader(Object input);  GeoTiffReader(Object input, Hints uHints); @Override int getGridCoverageCount(); @Override void dispose(); Format getFormat(); @Override GridCoverage2D read(GeneralParameterValue[] params); GeoTiffIIOMetadataDecoder getMetadata();  }