CoverageUtilities { public static boolean checkEmptySourceRegion(final ImageReadParam readParameters, final Rectangle dimensions) { Utilities.ensureNonNull("readDimension", dimensions); Utilities.ensureNonNull("readP", readParameters); final Rectangle sourceRegion = readParameters.getSourceRegion(); Rectangle.intersect(sourceRegion, dimensions, sourceRegion); if (sourceRegion.isEmpty()) { return true; } readParameters.setSourceRegion(sourceRegion); return false; } private  CoverageUtilities(); static CoordinateReferenceSystem getCRS2D(final Coverage coverage); static CoordinateReferenceSystem getHorizontalCRS(final Coverage coverage); static Envelope2D getEnvelope2D(final Coverage coverage); static double[] getBackgroundValues(GridCoverage2D coverage); static boolean hasRenderingCategories(final GridCoverage gridCoverage); static boolean hasTransform(final SampleDimension[] sampleDimensions); static boolean uses(final GridCoverage coverage, final RenderedImage image); static int getVisibleBand(final Object image); static ViewType preferredViewForOperation(final GridCoverage2D coverage,
            final Interpolation interpolation, final boolean hasFilter, final RenderingHints hints); static ViewType preferredViewAfterOperation(final GridCoverage2D coverage); static boolean isScaleTranslate(final MathTransform transform, final double EPS); static double[] getResolution(final AffineTransform gridToCRS); static boolean isSimpleGridToWorldTransform(final AffineTransform gridToCRS, double EPS); static boolean checkEmptySourceRegion(final ImageReadParam readParameters, 
            final Rectangle dimensions); static double getMosaicThreshold(int dataType); static Number suggestNoDataValue(int dataType); static final InternationalString NODATA; static final AffineTransform AXES_SWAP; static final AffineTransform IDENTITY_TRANSFORM; final static AffineTransform CENTER_TO_CORNER; final static AffineTransform CORNER_TO_CENTER; }
@Test public void testCheckEmptySourceRegion() { final ImageReadParam params = new ImageReadParam(); Rectangle sourceRegion = new Rectangle(300, 300, 700, 700); params.setSourceRegion(sourceRegion); Assert.assertEquals(sourceRegion.x, 300); Assert.assertEquals(sourceRegion.y, 300); Assert.assertEquals(sourceRegion.height, 700); Assert.assertEquals(sourceRegion.width, 700); final Rectangle intersecting = new Rectangle(400, 400, 900, 900); boolean isEmpty = CoverageUtilities.checkEmptySourceRegion(params, intersecting); Assert.assertFalse(isEmpty); final Rectangle intersection = params.getSourceRegion(); Assert.assertEquals(intersection.x, 400); Assert.assertEquals(intersection.y, 400); Assert.assertEquals(intersection.height, 600); Assert.assertEquals(intersection.width, 600); final Rectangle intersecting2 = new Rectangle(0, 0, 300, 300); isEmpty = CoverageUtilities.checkEmptySourceRegion(params, intersecting2); Assert.assertTrue(isEmpty); }