// //
//
// Doing the Operation
//
// //
final ParameterValueGroup param = BANDMERGE.getParameters();
// //
//
// ROI extraction
//
// //
Geometry geo = null;
if (roi != null) {
geo = roi;
Object crsGeo = geo.getUserData();
if (crsGeo != null && crsGeo instanceof CoordinateReferenceSystem) {
CoordinateReferenceSystem geoCRS = (CoordinateReferenceSystem) crsGeo;
GridCoverage2D cov = coverages.iterator().next();
// CRS Check
BaseCoverageAlgebraProcess.checkCompatibleCRS(geoCRS,
cov.getCoordinateReferenceSystem());
// Setting of the ROI if present
param.parameter(BandMerge.GEOMETRY).setValue(geo);
} else {
// Supposing that the Geometry has the same CRS of the Coverage
param.parameter(BandMerge.GEOMETRY).setValue(geo);
}
}
// Addition of all the Coverages as source
param.parameter("sources").setValue(coverages);
// Addition of the Transformation Choice parameter if present
if (transformChoice != null && !transformChoice.isEmpty()) {
param.parameter(BandMerge.TRANSFORM_CHOICE).setValue(transformChoice);
}
// Addition of the Index parameter to use by the Transformation Choice if present
if (transformChoice != null && !transformChoice.isEmpty()) {
param.parameter(BandMerge.COVERAGE_INDEX).setValue(index);
}
// Call the "BandMerge" operation
return (GridCoverage2D) PROCESSOR.doOperation(param);
}