}
if (name.getLocalPart().equals("pos")) {
CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem();
GeographicCRS spatialCRS = null;
if (crs instanceof CompoundCRS) {
List CRSs = ((DefaultCompoundCRS) crs).getCoordinateReferenceSystems();
for (Object item : CRSs) {
if (item instanceof GeographicCRS) {
spatialCRS = (GeographicCRS) item;
}
}
} else {
spatialCRS = (GeographicCRS) envelope.getCoordinateReferenceSystem();
}
if (spatialCRS != null) {
List<DirectPosition> envelopePositions = new LinkedList<DirectPosition>();
GeneralDirectPosition lowerCorner = new GeneralDirectPosition(envelope.getCoordinateReferenceSystem());
GeneralDirectPosition upperCorner = new GeneralDirectPosition(envelope.getCoordinateReferenceSystem());
for (int i = 0; i < spatialCRS.getCoordinateSystem().getDimension(); i++) {
lowerCorner.setOrdinate(i, envelope.getLowerCorner().getOrdinate(i));
upperCorner.setOrdinate(i, envelope.getUpperCorner().getOrdinate(i));
}
envelopePositions.add(lowerCorner);