@Test public void testCropHighestLevel() throws IOException, MismatchedDimensionException, NoSuchAuthorityCodeException { final URL testFile = TestData.getResource(this, TEST_FILE); final AbstractGridFormat format = new ImagePyramidFormat(); final ImagePyramidReader reader = (ImagePyramidReader) format.getReader(testFile); assertNotNull(reader); final ParameterValue<GridGeometry2D> gg = ImageMosaicFormat.READ_GRIDGEOMETRY2D.createValue(); final GeneralEnvelope oldEnvelop = reader.getOriginalEnvelope(); final GeneralEnvelope cropEnvelope = new GeneralEnvelope(new double[] { oldEnvelop.getLowerCorner().getOrdinate(0), oldEnvelop.getLowerCorner().getOrdinate(1) }, new double[] { oldEnvelop.getLowerCorner().getOrdinate(0) + oldEnvelop.getSpan(0) / 2, oldEnvelop.getLowerCorner().getOrdinate(1) + oldEnvelop.getSpan(1) / 2 }); cropEnvelope.setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); gg.setValue(new GridGeometry2D(new GridEnvelope2D(new Rectangle(0, 0, 250, 250)), cropEnvelope)); GridCoverage2D coverage = ((GridCoverage2D) reader .read(new GeneralParameterValue[] { gg })); assertNotNull("Null value returned instead of a coverage", coverage); assertTrue("coverage dimensions different from what we expected", coverage.getGridGeometry().getGridRange().getSpan(0) == 254 && coverage.getGridGeometry().getGridRange().getSpan( 1) == 254); if (TestData.isInteractiveTest()) coverage.show("testCropHighestLevel"); else PlanarImage.wrapRenderedImage(coverage.getRenderedImage()).getTiles(); }
@SuppressWarnings("unchecked") public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { GeneralEnvelope requestedEnvelope = null; Rectangle dim = null; OverviewPolicy overviewPolicy=null; if (params != null) { if (params != null) { for (int i = 0; i < params.length; i++) { final ParameterValue param = (ParameterValue) params[i]; if (param == null){ continue; } final String name = param.getDescriptor().getName().getCode(); if (name.equals(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString())) { final GridGeometry2D gg = (GridGeometry2D) param.getValue(); requestedEnvelope = new GeneralEnvelope((Envelope)gg.getEnvelope2D()); dim = gg.getGridRange2D().getBounds(); continue; } if (name.equals(AbstractGridFormat.OVERVIEW_POLICY.getName().toString())) { overviewPolicy = (OverviewPolicy) param.getValue(); continue; } } } } return loadTiles(requestedEnvelope, dim, params, overviewPolicy); }
ImagePyramidReader extends AbstractGridCoverage2DReader implements GridCoverageReader { @SuppressWarnings("unchecked") public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { GeneralEnvelope requestedEnvelope = null; Rectangle dim = null; OverviewPolicy overviewPolicy=null; if (params != null) { if (params != null) { for (int i = 0; i < params.length; i++) { final ParameterValue param = (ParameterValue) params[i]; if (param == null){ continue; } final String name = param.getDescriptor().getName().getCode(); if (name.equals(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString())) { final GridGeometry2D gg = (GridGeometry2D) param.getValue(); requestedEnvelope = new GeneralEnvelope((Envelope)gg.getEnvelope2D()); dim = gg.getGridRange2D().getBounds(); continue; } if (name.equals(AbstractGridFormat.OVERVIEW_POLICY.getName().toString())) { overviewPolicy = (OverviewPolicy) param.getValue(); continue; } } } } return loadTiles(requestedEnvelope, dim, params, overviewPolicy); } }
ImagePyramidReader extends AbstractGridCoverage2DReader implements GridCoverageReader { @SuppressWarnings("unchecked") public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { GeneralEnvelope requestedEnvelope = null; Rectangle dim = null; OverviewPolicy overviewPolicy=null; if (params != null) { if (params != null) { for (int i = 0; i < params.length; i++) { final ParameterValue param = (ParameterValue) params[i]; if (param == null){ continue; } final String name = param.getDescriptor().getName().getCode(); if (name.equals(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString())) { final GridGeometry2D gg = (GridGeometry2D) param.getValue(); requestedEnvelope = new GeneralEnvelope((Envelope)gg.getEnvelope2D()); dim = gg.getGridRange2D().getBounds(); continue; } if (name.equals(AbstractGridFormat.OVERVIEW_POLICY.getName().toString())) { overviewPolicy = (OverviewPolicy) param.getValue(); continue; } } } } return loadTiles(requestedEnvelope, dim, params, overviewPolicy); } ImagePyramidReader(Object source, Hints uHints);  ImagePyramidReader(Object source); }
ImagePyramidReader extends AbstractGridCoverage2DReader implements GridCoverageReader { @SuppressWarnings("unchecked") public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { GeneralEnvelope requestedEnvelope = null; Rectangle dim = null; OverviewPolicy overviewPolicy=null; if (params != null) { if (params != null) { for (int i = 0; i < params.length; i++) { final ParameterValue param = (ParameterValue) params[i]; if (param == null){ continue; } final String name = param.getDescriptor().getName().getCode(); if (name.equals(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString())) { final GridGeometry2D gg = (GridGeometry2D) param.getValue(); requestedEnvelope = new GeneralEnvelope((Envelope)gg.getEnvelope2D()); dim = gg.getGridRange2D().getBounds(); continue; } if (name.equals(AbstractGridFormat.OVERVIEW_POLICY.getName().toString())) { overviewPolicy = (OverviewPolicy) param.getValue(); continue; } } } } return loadTiles(requestedEnvelope, dim, params, overviewPolicy); } ImagePyramidReader(Object source, Hints uHints);  ImagePyramidReader(Object source); Format getFormat(); @SuppressWarnings("unchecked") GridCoverage2D read(GeneralParameterValue[] params); @Override synchronized void dispose(); @Override int getGridCoverageCount(); }
ImagePyramidReader extends AbstractGridCoverage2DReader implements GridCoverageReader { @SuppressWarnings("unchecked") public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { GeneralEnvelope requestedEnvelope = null; Rectangle dim = null; OverviewPolicy overviewPolicy=null; if (params != null) { if (params != null) { for (int i = 0; i < params.length; i++) { final ParameterValue param = (ParameterValue) params[i]; if (param == null){ continue; } final String name = param.getDescriptor().getName().getCode(); if (name.equals(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString())) { final GridGeometry2D gg = (GridGeometry2D) param.getValue(); requestedEnvelope = new GeneralEnvelope((Envelope)gg.getEnvelope2D()); dim = gg.getGridRange2D().getBounds(); continue; } if (name.equals(AbstractGridFormat.OVERVIEW_POLICY.getName().toString())) { overviewPolicy = (OverviewPolicy) param.getValue(); continue; } } } } return loadTiles(requestedEnvelope, dim, params, overviewPolicy); } ImagePyramidReader(Object source, Hints uHints);  ImagePyramidReader(Object source); Format getFormat(); @SuppressWarnings("unchecked") GridCoverage2D read(GeneralParameterValue[] params); @Override synchronized void dispose(); @Override int getGridCoverageCount();  }