public void write(final GridCoverage gc,
final GeneralParameterValue[] params)
throws IllegalArgumentException, IOException,
IndexOutOfBoundsException {
GeoToolsWriteParams gtParams = null;
boolean writeTfw=GeoTiffFormat.WRITE_TFW.getDefaultValue();
ProgressListener listener=null;
boolean retainAxesOrder = false;
if (params != null) {
// /////////////////////////////////////////////////////////////////////
//
// Checking params
//
// /////////////////////////////////////////////////////////////////////
if (params != null) {
Parameter<?> param;
final int length = params.length;
for (int i = 0; i < length; i++) {
param = (Parameter) params[i];
final ReferenceIdentifier name=param.getDescriptor().getName();
if (name.equals(AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName())) {
gtParams = (GeoToolsWriteParams) param.getValue();
continue;
}
if (name.equals(GeoTiffFormat.WRITE_TFW.getName())){
writeTfw = (Boolean) param.getValue();
continue;
}
if (name.equals(GeoTiffFormat.PROGRESS_LISTENER.getName())) {
listener = (ProgressListener) param.getValue();
continue;
}
if (name.equals(GeoTiffFormat.RETAIN_AXES_ORDER.getName())) {
retainAxesOrder = (Boolean) param.getValue();
continue;
}
}
}
}
if (gtParams == null)
gtParams = new GeoTiffWriteParams();
//
// getting the coordinate reference system
//
final GridGeometry2D gg = (GridGeometry2D) gc.getGridGeometry();
GridEnvelope2D range = gg.getGridRange2D();
final Rectangle sourceRegion = gtParams.getSourceRegion();
if (sourceRegion != null){
range = new GridEnvelope2D(sourceRegion);
}
final AffineTransform tr = (AffineTransform) gg.getGridToCRS2D();
final CoordinateReferenceSystem crs = gg.getCoordinateReferenceSystem2D();