}
// XXX Optimize when referenced envelope has intersection method that actually retains the CRS, this is the JTS one
requestedBBox=new ReferencedEnvelope(((ReferencedEnvelope) requestedBBox).intersection(coverageBBox),coverageCRS2D);
//compute approximate full resolution
// compute the approximated full resolution in wgs84
final GridToEnvelopeMapper geMapper= new GridToEnvelopeMapper(new GridEnvelope2D(requestedRasterArea),requestedBBox);
requestedResolution=CoverageUtilities.getResolution(geMapper.createAffineTransform());
return;
} catch (TransformException te) {
// something bad happened while trying to transform this
// envelope. let's try with wgs84
if(LOGGER.isLoggable(Level.FINE))
LOGGER.log(Level.FINE,te.getLocalizedMessage(),te);
}
// //
//
// If this does not work, we go back to reproject in the wgs84
// requested envelope
//
// //
//convert to WGS84
final GeographicBoundingBoxImpl geographicRequestedBBox = new GeographicBoundingBoxImpl(requestedBBox);
ReferencedEnvelope approximateWGS84requestedBBox =GridCoverageUtilities.getReferencedEnvelopeFromGeographicBoundingBox(geographicRequestedBBox);
// checking the intersection in wgs84 with the geographicbbox for this coverage
if (!approximateWGS84requestedBBox.intersects((BoundingBox)coverageGeographicBBox))
{
requestedBBox = null;
return;
}
//compute approximate full resolution
// compute the approximated full resolution in wgs84
final GridToEnvelopeMapper geMapper= new GridToEnvelopeMapper(new GridEnvelope2D(requestedRasterArea),approximateWGS84requestedBBox);
approximateWGS84RequestedResolution=CoverageUtilities.getResolution(geMapper.createAffineTransform());
// intersect with the coverage native WGS84 bbox
// note that for the moment we got to use general envelope since there is no intersection othrewise
// TODO fix then we'll have intersection in ReferencedEnvelope
approximateWGS84requestedBBox=new ReferencedEnvelope(approximateWGS84requestedBBox.intersection(coverageGeographicBBox),DefaultGeographicCRS.WGS84);