public ReferencedEnvelope boundingBox() throws Exception {
CoordinateReferenceSystem declaredCRS = getCRS();
CoordinateReferenceSystem nativeCRS = getNativeCRS();
ProjectionPolicy php = getProjectionPolicy();
ReferencedEnvelope nativeBox = this.nativeBoundingBox;
if (nativeBox == null) {
try {
nativeBox = getLatLonBoundingBox().transform(declaredCRS, true);
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Failed to derive native bbox from declared one", e);
return null;
}
}
ReferencedEnvelope result;
if (!CRS.equalsIgnoreMetadata(declaredCRS, nativeCRS)
&& php == ProjectionPolicy.REPROJECT_TO_DECLARED) {
result = nativeBox.transform(declaredCRS, true);
} else if (php == ProjectionPolicy.FORCE_DECLARED) {
result = ReferencedEnvelope.create((Envelope) nativeBox, declaredCRS);
} else {
result = nativeBox;
}
return ReferencedEnvelope.create(result);
}