}
private static GridCoverage2D projectTo(final GridCoverage2D coverage,
final CoordinateReferenceSystem targetCRS, final GridGeometry2D geometry,
final Hints hints, final boolean useGeophysics) {
final CoverageProcessor processor = (hints != null) ? CoverageProcessor.getInstance(hints)
: CoverageProcessor.getInstance();
final String arg1;
final Object value1;
final String arg2;
final Object value2;
if (targetCRS != null) {
arg1 = "CoordinateReferenceSystem";
value1 = targetCRS;
if (geometry != null) {
arg2 = "GridGeometry";
value2 = geometry;
} else {
arg2 = "InterpolationType";
value2 = "bilinear";
}
} else {
arg1 = "GridGeometry";
value1 = geometry;
arg2 = "InterpolationType";
value2 = "bilinear";
}
GridCoverage2D projected = coverage.geophysics(useGeophysics);
final ParameterValueGroup param = processor.getOperation("Resample").getParameters();
param.parameter("Source").setValue(projected);
param.parameter(arg1).setValue(value1);
param.parameter(arg2).setValue(value2);
projected = (GridCoverage2D) processor.doOperation(param);
final RenderedImage image = projected.getRenderedImage();
projected = projected.geophysics(false);
String operation = null;