}
private void checkDomainSubset(CoverageInfo meta, DomainSubsetType domainSubset)
throws Exception {
BoundingBoxType bbox = domainSubset.getBoundingBox();
// workaround for http://jira.codehaus.org/browse/GEOT-1710
if("urn:ogc:def:crs:OGC:1.3:CRS84".equals(bbox.getCrs()))
bbox.setCrs("EPSG:4326");
CoordinateReferenceSystem bboxCRs = CRS.decode(bbox.getCrs());
Envelope gridEnvelope = meta.getGridCoverage(null, HINTS).getEnvelope();
GeneralEnvelope gridEnvelopeBboxCRS = null;
if (bboxCRs instanceof GeographicCRS) {
try {
CoordinateOperationFactory cof = CRS.getCoordinateOperationFactory(true);
final CoordinateOperation operation = cof.createOperation(gridEnvelope
.getCoordinateReferenceSystem(), bboxCRs);
gridEnvelopeBboxCRS = CRS.transform(operation, gridEnvelope);
} catch (Exception e) {
// this may happen, there is nothing we can do about it, we just
// use the back transformed envelope to be more lenient about
// which coordinate coorections to make on the longitude axis
// should the antimeridian style be used
}
}
// check the coordinates, but make sure the case 175,-175 is handled
// as valid for the longitude axis in a geographic coordinate system
// see section 7.6.2 of the WCS 1.1.1 spec)
List<Double> lower = bbox.getLowerCorner();
List<Double> upper = bbox.getUpperCorner();
for (int i = 0; i < lower.size(); i++) {
if (lower.get(i) > upper.get(i)) {
final CoordinateSystemAxis axis = bboxCRs.getCoordinateSystem().getAxis(i);
// see if the coordinates can be fixed
if (bboxCRs instanceof GeographicCRS && axis.getDirection() == AxisDirection.EAST) {