public BoundingBox extendMargin(float margin) {
        if (margin == 1) {
            return this;
        } else if (margin <= 0) {
            throw new IllegalArgumentException("BoundingBox extend operation does not accept negative or zero values");
        }

        double verticalExpansion = (this.getLatitudeSpan() * margin - this.getLatitudeSpan()) * 0.5;
        double horizontalExpansion = (this.getLongitudeSpan() * margin - this.getLongitudeSpan()) * 0.5;

        double minLat = Math.max(MercatorProjection.LATITUDE_MIN, this.minLatitude - verticalExpansion);
        double minLon = Math.max(-180, this.minLongitude - horizontalExpansion);
        double maxLat = Math.min(MercatorProjection.LATITUDE_MAX, this.maxLatitude + verticalExpansion);
        double maxLon = Math.min(180, this.maxLongitude + horizontalExpansion);

        return new BoundingBox(minLat, minLon, maxLat, maxLon);
    }
public BoundingBox extendMargin ( float margin ) { if ( margin == 1 ) { return this ; } else if ( margin <= 0 ) { throw new IllegalArgumentException ( "BoundingBox extend operation does not accept negative or zero values" ) ; } double verticalExpansion = ( this . getLatitudeSpan ( ) * margin - this . getLatitudeSpan ( ) ) * 0.5 ; double horizontalExpansion = ( this . getLongitudeSpan ( ) * margin - this . getLongitudeSpan ( ) ) * 0.5 ; double minLat = Math . max ( MercatorProjection . LATITUDE_MIN , this . minLatitude - verticalExpansion ) ; double minLon = Math . max ( - 180 , this . minLongitude - horizontalExpansion ) ; double maxLat = Math . min ( MercatorProjection . LATITUDE_MAX , this . maxLatitude + verticalExpansion ) ; double maxLon = Math . min ( 180 , this . maxLongitude + horizontalExpansion ) ; return new BoundingBox ( minLat , minLon , maxLat , maxLon ) ; }
Creates a BoundingBox that is a fixed margin factor larger on all sides (but does not cross date line/poles).

@param margin extension (must be > 0)
@return an extended BoundingBox or this (if margin == 1)