'Compute a bounding box given a Radius (in km) of a LatLon Location
Note the order of the parameters.
@return a dict containing the bounds with keys min_lon, max_lon,
min_lat, max_lat
See:
http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates'

@staticmethod
def get_bounds_from_radius(lat, lon, radius):

    import math
    radians = math.radians
    degrees = math.degrees
    MIN_LAT = radians((-90))
    MAX_LAT = radians(90)
    MIN_LON = radians((-180))
    MAX_LON = radians(180)
    r = (float(radius) / RADIUS_EARTH)
    radLat = radians(lat)
    radLon = radians(lon)
    minLat = (radLat - r)
    maxLat = (radLat + r)
    if ((minLat > MIN_LAT) and (maxLat < MAX_LAT)):
        deltaLon = math.asin((math.sin(r) / math.cos(radLat)))
        minLon = (radLon - deltaLon)
        if (minLon < MIN_LON):
            minLon += (2 * math.pi)
        maxLon = (radLon + deltaLon)
        if (maxLon > MAX_LON):
            maxLon -= (2 * math.pi)
    else:
        minLat = max(minLat, MIN_LAT)
        maxLat = min(maxLat, MAX_LAT)
        minLon = MIN_LON
        maxLon = MAX_LON
    minLat = degrees(minLat)
    minLon = degrees(minLon)
    maxLat = degrees(maxLat)
    maxLon = degrees(maxLon)
    return dict(lat_min=minLat, lat_max=maxLat, lon_min=minLon, lon_max=maxLon)
