.asList(parameters));
for (GeneralParameterValue lparam : limitParams) {
// remove the overwritten param, if any
final GeneralParameterDescriptor ldescriptor = lparam.getDescriptor();
for (Iterator it = params.iterator(); it.hasNext();) {
GeneralParameterValue param = (GeneralParameterValue) it.next();
if (param.getDescriptor().equals(lparam.getDescriptor())) {
it.remove();
break;
}
}
// add the overwrite param (will be an overwrite if it was already there, an
// addition otherwise)
params.add(lparam);
}
parameters = (GeneralParameterValue[]) params
.toArray(new GeneralParameterValue[params.size()]);
}
if(readFilter != null && !Filter.INCLUDE.equals(readFilter)) {
ParameterValueGroup readParameters = delegate.getFormat().getReadParameters();
List<GeneralParameterDescriptor> descriptors = readParameters.getDescriptor().descriptors();
parameters = CoverageUtils.mergeParameter(descriptors,
parameters, readFilter, "FILTER", "Filter");
}
}
GridCoverage2D grid = delegate.read(parameters);
// crop if necessary
if (rasterFilter != null) {
Geometry coverageBounds = JTS.toGeometry((Envelope) new ReferencedEnvelope(grid.getEnvelope2D()));
if(coverageBounds.intersects(rasterFilter)) {
final ParameterValueGroup param = (ParameterValueGroup) cropParams.clone();
param.parameter("source").setValue(grid);
param.parameter("ROI").setValue(rasterFilter);
grid = (GridCoverage2D) coverageCropFactory.doOperation(param, null);
} else {
return null;
}
}