param.parameter(Mosaic.POLICY).setValue("coarse");
// Mosaic
GridCoverage2D mosaic = (GridCoverage2D) processor.doOperation(param);
// Check that the final GridCoverage BoundingBox is equal to the union of the separate coverages bounding box
Envelope2D expected = coverage1.getEnvelope2D();
expected.include(resampled.getEnvelope2D());
// Mosaic Envelope
Envelope2D actual = mosaic.getEnvelope2D();
// Check the same Bounding Box
assertEqualBBOX(expected, actual);
// Check that the final Coverage resolution is equal to that of the first coverage
double initialRes = calculateResolution(coverage1);
double finalRes = calculateResolution(mosaic);
double percentual = Math.abs(initialRes - finalRes) / initialRes;
Assert.assertTrue(percentual < TOLERANCE);
// Check that on the center of the image there are nodata
DirectPosition point = new DirectPosition2D(mosaic.getCoordinateReferenceSystem(),
actual.getCenterX(), actual.getCenterY());
double nodata = CoverageUtilities.getBackgroundValues(coverage1)[0];
double result = ((int[]) mosaic.evaluate(point))[0];
Assert.assertEquals(nodata, result, TOLERANCE);
// Check that on the Upper Left border pixel there is valid data
point = new DirectPosition2D(mosaic.getCoordinateReferenceSystem(), actual.getMinX()
+ finalRes, actual.getMinY() + finalRes);
result = ((int[]) mosaic.evaluate(point))[0];
Assert.assertNotEquals(nodata, result, TOLERANCE);
// Coverage and RenderedImage disposal
mosaic.dispose(true);