public BoundingBox overlap ( BoundingBox boundingBox , boolean allowEmpty ) { double minLongitude = Math . max ( getMinLongitude ( ) , boundingBox . getMinLongitude ( ) ) ; double maxLongitude = Math . min ( getMaxLongitude ( ) , boundingBox . getMaxLongitude ( ) ) ; double minLatitude = Math . max ( getMinLatitude ( ) , boundingBox . getMinLatitude ( ) ) ; double maxLatitude = Math . min ( getMaxLatitude ( ) , boundingBox . getMaxLatitude ( ) ) ; BoundingBox overlap = null ; if ( ( minLongitude < maxLongitude && minLatitude < maxLatitude ) || ( allowEmpty && minLongitude <= maxLongitude && minLatitude <= maxLatitude ) ) { overlap = new BoundingBox ( minLongitude , minLatitude , maxLongitude , maxLatitude ) ; } return overlap ; }
Get the overlapping bounding box with the provided bounding box