/** * Method for checking if Alpha Coverage and Image Coverage have the same dimensions * * @param coverage * @param alpha */ private static void checkAlpha(GridCoverage2D coverage, GridCoverage2D alpha) { // Check GridGeometries if (!coverage.getGridGeometry().equals(alpha.getGridGeometry())) { throw new CoverageProcessingException( "Alpha Coverage and Source Coverage does not have the same dimensions"); } }
/** * Checks if two geometries are equal, ignoring unspecified fields. If one or both geometries * has no "gridToCRS" transform, then this properties is not taken in account. Same apply for * the grid range. * * @param sourceGG The source geometry (never {@code null}). * @param targetGG The target geometry. May be {@code null}, which is considered as equivalent. * @return {@code true} if the two geometries are equal, ignoring unspecified fields. */ private static boolean equivalent( final GridGeometry2D sourceGG, final GridGeometry2D targetGG) { if (targetGG == null || targetGG.equals(sourceGG)) { return true; } if (targetGG.isDefined(GridGeometry2D.GRID_RANGE_BITMASK) && sourceGG.isDefined(GridGeometry2D.GRID_RANGE_BITMASK)) { if (!targetGG.getGridRange().equals(sourceGG.getGridRange())) { return false; } } if (targetGG.isDefined(GridGeometry2D.GRID_TO_CRS_BITMASK) && sourceGG.isDefined(GridGeometry2D.GRID_TO_CRS_BITMASK)) { // No needs to ask for a transform relative to a corner // since we will not apply a transformation here. if (!targetGG.getGridToCRS().equals(sourceGG.getGridToCRS())) { return false; } } return true; }
GridGeometry2D gg = coverage.getGridGeometry(); GridGeometry2D reduced = reducer.reduce(gg); if (!reduced.equals(gg)) { GeneralEnvelope cutEnvelope = reducer.getCutEnvelope(reduced); GridCoverage2D croppedCoverage = crop(coverage, cutEnvelope, false, bgValues);
layout = new ImageLayout(); layout.setColorModel(cm); } else if (!gg.equals(gridGeometry)) throw new IllegalArgumentException( Errors.format(ErrorKeys.MUST_SHARE_GRIDGEOMETRY_$1, "BandMerge"));
/** * Checks if two geometries are equal, ignoring unspecified fields. If one or both * geometries has no "gridToCRS" transform, then this properties is not taken in account. * Same apply for the grid range. * * @param range1 The first range. * @param range2 The second range. * @return {@code true} if the two geometries are equal, ignoring unspecified fields. */ private static boolean equivalent(final GridGeometry2D geom1, final GridGeometry2D geom2) { if (geom1.equals(geom2)) { return true; } if (geom1.isDefined(GridGeometry2D.GRID_RANGE) && geom2.isDefined(GridGeometry2D.GRID_RANGE)) { if (!geom1.getGridRange().equals(geom2.getGridRange())) { return false; } } if (geom1.isDefined(GridGeometry2D.GRID_TO_CRS) && geom2.isDefined(GridGeometry2D.GRID_TO_CRS)) { if (!geom1.getGridToCRS().equals(geom2.getGridToCRS())) { return false; } } return true; }
if (targetGG == null || targetGG.equals(sourceGG)) { return true;
layout = new ImageLayout(); layout.setColorModel(cm); } else if (!gg.equals(gridGeometry)) throw new IllegalArgumentException(Errors.format( ErrorKeys.MUST_SHARE_GRIDGEOMETRY_$1, "BandMerge"));
bandSelectedCoverage.getGridGeometry().equals(destinationGridGeometry); if (reprojectionNeeded || !sameGridGeometry) { final GridCoverage2D reprojectedCoverage =