Map grid = cInfoReader.grid();
if ( grid != null ) {
int[] low = (int[]) grid.get( "low" );
int[] high = (int[]) grid.get( "high" );
GeneralGridEnvelope range = new GeneralGridEnvelope(low, high);
Map<String,Double> tx = (Map<String, Double>) grid.get( "geoTransform" );
if ( tx != null ) {
double[] matrix = new double[3 * 3];
matrix[0] = tx.get( "scaleX") != null ? tx.get( "scaleX") : matrix[0];
matrix[1] = tx.get( "shearX") != null ? tx.get( "shearX") : matrix[1];
matrix[2] = tx.get( "translateX") != null ? tx.get( "translateX") : matrix[2];
matrix[3] = tx.get( "shearY") != null ? tx.get( "shearY") : matrix[3];
matrix[4] = tx.get( "scaleY") != null ? tx.get( "scaleY") : matrix[4];
matrix[5] = tx.get( "translateY") != null ? tx.get( "translateY") : matrix[5];
matrix[8] = 1.0;
MathTransform gridToCRS = new DefaultMathTransformFactory()
.createAffineTransform( new GeneralMatrix(3,3,matrix));
coverage.setGrid( new GridGeometry2D(range,gridToCRS,crs) );
}
else {
coverage.setGrid( new GridGeometry2D( range, gridEnvelope ) );
}
}
else {
// new grid range
GeneralGridEnvelope range = new GeneralGridEnvelope(new int[] { 0,
0 }, new int[] { 1, 1 });
coverage.setGrid( new GridGeometry2D(range, gridEnvelope) );
}
for ( Iterator x = cInfoReader.coverageDimensions().iterator(); x .hasNext(); ) {