return offsets;
}
private void checkDomainSubset(CoverageInfo meta, DomainSubsetType domainSubset, WCSInfo wcs)
throws Exception {
BoundingBoxType bbox = domainSubset.getBoundingBox();
// domain subset should actually be always specified, but we try to be more lenient
// (we should probably have a "strict cite" behavior
if (bbox == null) {
return;
}
// 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());
GridCoverage2DReader reader = (GridCoverage2DReader) meta.getGridCoverageReader(null,
WCSUtils.getReaderHints(wcs));
Envelope gridEnvelope = reader.getOriginalEnvelope();
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) {