public void extend ( LatLonRect r ) { Preconditions . checkNotNull ( r ) ; // lat is easy double latMin = r . getLatMin ( ) ; double latMax = r . getLatMax ( ) ; if ( latMax > upperRight . getLatitude ( ) ) { upperRight . setLatitude ( latMax ) ; } if ( latMin < lowerLeft . getLatitude ( ) ) { lowerLeft . setLatitude ( latMin ) ; } // lon is uglier if ( allLongitude ) return ; // everything is reletive to current LonMin double lonMin = getLonMin ( ) ; double lonMax = getLonMax ( ) ; double nlonMin = LatLonPointImpl . lonNormal ( r . getLonMin ( ) , lonMin ) ; double nlonMax = nlonMin + r . getWidth ( ) ; lonMin = Math . min ( lonMin , nlonMin ) ; lonMax = Math . max ( lonMax , nlonMax ) ; width = lonMax - lonMin ; allLongitude = width >= 360.0 ; if ( allLongitude ) { width = 360.0 ; lonMin = - 180.0 ; } else { lonMin = LatLonPointImpl . lonNormal ( lonMin ) ; } lowerLeft . setLongitude ( lonMin ) ; upperRight . setLongitude ( lonMin + width ) ; lon0 = lonMin + width / 2 ; crossDateline = lowerLeft . getLongitude ( ) > upperRight . getLongitude ( ) ; }
Extend the bounding box to contain the given rectangle