@Test
  @Ignore
public void testExternalOverviews() throws Exception {

    final File file = TestData.file(GeoTiffReaderTest.class, "ovr.tif");
    assertNotNull(file);
    assertEquals(true, file.exists());
    GeoTiffReader reader = new GeoTiffReader(file);
    final int nOvrs = reader.getNumOverviews();
    LOGGER.info("Number of external overviews: " + nOvrs);
    assertEquals(4, nOvrs);
    double[][] availableResolutions = reader.getResolutionLevels();
    assertEquals(availableResolutions.length, 5);
    
    final ParameterValue<GridGeometry2D> gg =  AbstractGridFormat.READ_GRIDGEOMETRY2D.createValue();
    final GeneralEnvelope envelope = reader.getOriginalEnvelope();
    final Dimension dim = new Dimension();
    dim.setSize(reader.getOriginalGridRange().getSpan(0)/64.0, reader.getOriginalGridRange().getSpan(1)/64.0);
    final Rectangle rasterArea=(( GridEnvelope2D)reader.getOriginalGridRange());
    rasterArea.setSize(dim);
    final GridEnvelope2D range= new GridEnvelope2D(rasterArea);
    GridGeometry2D gridGeometry = new GridGeometry2D(range,envelope);
    gg.setValue(gridGeometry);
    GridCoverage2D coverage = reader.read(new GeneralParameterValue[] {gg});
    assertEquals(coverage.getEnvelope(), reader.getOriginalEnvelope());
    RenderedImage image = coverage.getRenderedImage();
    assertEquals(image.getWidth(), 2);
    assertEquals(image.getHeight(), 2);
    
    final double delta = 0.00001;
    assertEquals(availableResolutions[0][0], 5, delta);
    assertEquals(availableResolutions[0][1], 5, delta);
    
    assertEquals(availableResolutions[1][0], 10, delta);
    assertEquals(availableResolutions[1][1], 10, delta);
    assertEquals(availableResolutions[2][0], 20, delta);
    assertEquals(availableResolutions[2][1], 20, delta);
    assertEquals(availableResolutions[3][0], 40, delta);
    assertEquals(availableResolutions[3][1], 40, delta);
    
    assertEquals(availableResolutions[4][0], 80, delta);
    assertEquals(availableResolutions[4][1], 80, delta);
    
    MathTransform transform = gridGeometry.getGridToCRS();
    AffineTransform affine = (AffineTransform) transform;
    double resX = XAffineTransform.getScaleX0(affine);
    double resY = XAffineTransform.getScaleY0(affine);
    // Using "poor" resolution (less than the worst available overview).
    double[] resolutions = reader.getReadingResolutions(OverviewPolicy.QUALITY, new double[]{resX, resY});
    // Checking that the reading resolution will be the one of the worst (last) overview
    assertEquals(resolutions[0], availableResolutions[nOvrs][0], delta);
    assertEquals(resolutions[1], availableResolutions[nOvrs][1], delta);
    // Using a middle resolution
    resolutions = reader.getReadingResolutions(OverviewPolicy.QUALITY, new double[]{resX/8, resY/8});
    assertEquals(resolutions[0], 40, delta);
    assertEquals(resolutions[1], 40, delta);
    // Using native resolution
    resolutions = reader.getReadingResolutions(OverviewPolicy.QUALITY, availableResolutions[0]);
    assertEquals(resolutions[0], availableResolutions[0][0], delta);
    assertEquals(resolutions[1], availableResolutions[0][1], delta);
}