if (node.getChild("lowerCorner") != null) {
DirectPosition l = (DirectPosition) node.getChildValue("lowerCorner");
DirectPosition u = (DirectPosition) node.getChildValue("upperCorner");
if (l.getDimension() > 2) {
return new ReferencedEnvelope3D(u.getOrdinate(0), l.getOrdinate(0), u.getOrdinate(1), l.getOrdinate(1), u.getOrdinate(2), l.getOrdinate(2), crs);
}
return new ReferencedEnvelope(u.getOrdinate(0), l.getOrdinate(0), u.getOrdinate(1), l.getOrdinate(1), crs);
}
if (node.hasChild(Coordinate.class)) {
List c = node.getChildValues(Coordinate.class);
Coordinate c1 = (Coordinate) c.get(0);
Coordinate c2 = (Coordinate) c.get(1);
if (!Double.isNaN(c1.z)) {
return new ReferencedEnvelope3D(c1.x, c2.x, c1.y, c2.y, c1.z, c1.z, crs);
} else {
return new ReferencedEnvelope(c1.x, c2.x, c1.y, c2.y, crs);
}
}
if (node.hasChild(DirectPosition.class)) {
List dp = node.getChildValues(DirectPosition.class);
DirectPosition dp1 = (DirectPosition) dp.get(0);
DirectPosition dp2 = (DirectPosition) dp.get(1);
if (dp1.getDimension() > 2) {
return new ReferencedEnvelope3D(dp1.getOrdinate(0), dp2.getOrdinate(0), dp1.getOrdinate(1), dp2.getOrdinate(1), dp1.getOrdinate(2), dp2.getOrdinate(2), crs);
} else {
return new ReferencedEnvelope(dp1.getOrdinate(0), dp2.getOrdinate(0),
dp1.getOrdinate(1), dp2.getOrdinate(1), crs);
}
}
if (node.hasChild(CoordinateSequence.class)) {
CoordinateSequence seq = (CoordinateSequence) node.getChildValue(CoordinateSequence.class);
if (seq.getDimension() > 2) {
return new ReferencedEnvelope3D(seq.getX(0), seq.getX(1), seq.getY(0), seq.getY(1), seq.getOrdinate (0, 2), seq.getOrdinate( 1, 2), crs);
} else {
return new ReferencedEnvelope(seq.getX(0), seq.getX(1), seq.getY(0), seq.getY(1), crs);
}
}