access.read(new GeoTiffAccess.Read<CoverageResponse>() {
public CoverageResponse run(GeoTiffReader reader,
GeoTiffAccess access) throws IOException {
// get the request elements
final BoundingBox bbox = request.getGeographicArea();
final Rectangle rasterArea = request.getRasterArea();
final MathTransform2D g2w = request
.getGridToWorldTransform();
final GridCoverage2D coverage;
if (g2w != null || rasterArea != null || g2w != null) {
final ParameterValue<GridGeometry2D> readParameter = AbstractGridFormat.READ_GRIDGEOMETRY2D
.createValue();
if (g2w == null) {
if (rasterArea == null) {
Info info = getInfo(null );
readParameter.setValue(new GridGeometry2D(
info.getGeometry().getGridRange2D(),
new ReferencedEnvelope(bbox)));
} else {
readParameter.setValue(new GridGeometry2D(
new GridEnvelope2D(rasterArea),
new ReferencedEnvelope(bbox)));
}
} else {
readParameter.setValue(new GridGeometry2D(
new GridEnvelope2D(rasterArea),
PixelInCell.CELL_CENTER, g2w, bbox
.getCoordinateReferenceSystem(),
null));
}
coverage = (GridCoverage2D) reader
.read(new GeneralParameterValue[] { readParameter });