Modified getBoundsInternal to handle 3D CRS