/** {@inheritDoc} */ @Override public CoordinateReferenceSystem getResponseCRS() throws FactoryException { if (output == null || output.getGridCRS() == null || output.getGridCRS().getSrsName() == null || output.getGridCRS().getSrsName().getValue() == null) { return null; } final CoordinateReferenceSystem objCrs = CRS.forCode(output.getGridCRS().getSrsName().getValue()); final BoundingBoxType boundingBox = domainSubset.getBoundingBox().getValue(); /* * If the bounding box contains at least 3 dimensions and the CRS specified is just * a 2D one, then we have to add a VerticalCRS to the one gotten by the crs decoding step. * Otherwise the CRS decoded is already fine, and we just return it. */ if (boundingBox.getDimensions().intValue() > 2 && objCrs.getCoordinateSystem().getDimension() < 3) { final VerticalCRS verticalCRS = CommonCRS.Vertical.ELLIPSOIDAL.crs(); return new GeodeticObjectBuilder() .addName(objCrs.getName().getCode() + " (3D)") .createCompoundCRS(objCrs, verticalCRS); } else { return objCrs; } }
/** {@inheritDoc} */ @Override public CoordinateReferenceSystem getCRS() throws FactoryException { if (domainSubset == null || domainSubset.getBoundingBox() == null) { return null; } final BoundingBoxType boundingBox = domainSubset.getBoundingBox().getValue(); final CoordinateReferenceSystem objCrs = AbstractCRS.castOrCopy(CRS.forCode(boundingBox.getCrs())) .forConvention(AxesConvention.RIGHT_HANDED); // final List<DirectPositionType> positions = // domainSubset.getSpatialSubSet().getEnvelope().getPos(); /* * If the bounding box contains at least 3 dimensions and the CRS specified is just * a 2D one, then we have to add a VerticalCRS to the one gotten by the crs decoding step. * Otherwise the CRS decoded is already fine, and we just return it. */ if (boundingBox.getUpperCorner().size() > 2 && objCrs.getCoordinateSystem().getDimension() < 3) { final VerticalCRS verticalCRS = CommonCRS.Vertical.ELLIPSOIDAL.crs(); return new GeodeticObjectBuilder() .addName(objCrs.getName().getCode() + " (3D)") .createCompoundCRS(objCrs, verticalCRS); } else { return objCrs; } }
/** {@inheritDoc} */ @Override public Envelope getEnvelope() throws FactoryException { if (domainSubset == null || domainSubset.getBoundingBox() == null) { return null; } final BoundingBoxType boundingBox = domainSubset.getBoundingBox().getValue(); final List<Double> lowerCorner = boundingBox.getLowerCorner(); final List<Double> upperCorner = boundingBox.getUpperCorner(); final CoordinateReferenceSystem crs = getCRS(); final GeneralEnvelope objEnv = new GeneralEnvelope(crs); objEnv.setRange(0, lowerCorner.get(0), upperCorner.get(0)); objEnv.setRange(1, lowerCorner.get(1), upperCorner.get(1)); // If the CRS has a vertical part, then the envelope to return should be a 3D one. if (CRS.getVerticalComponent(crs, true) != null) { objEnv.setRange(2, lowerCorner.get(2), upperCorner.get(2)); } return objEnv; }