def get_area_url(location, distance):
    """Generate URL for downloading OSM data within a region.

    This function defines a boundary box where the edges touch a circle of
    ``distance`` kilometres in radius.  It is important to note that the box is
    neither a square, nor bounded within the circle.

    The bounding box is strictly a trapezoid whose north and south edges are
    different lengths, which is longer is dependant on whether the box is
    calculated for a location in the Northern or Southern hemisphere.  You will
    get a shorter north edge in the Northern hemisphere, and vice versa.  This
    is simply because we are applying a flat transformation to a spherical
    object, however for all general cases the difference will be negligible.

    Args:
        location (Point): Centre of the region
        distance (int): Boundary distance in kilometres

    Returns:
        str: URL that can be used to fetch the OSM data within ``distance`` of
            ``location``
    """
    locations = [location.destination(i, distance) for i in range(0, 360, 90)]
    latitudes = list(map(attrgetter('latitude'), locations))
    longitudes = list(map(attrgetter('longitude'), locations))

    bounds = (min(longitudes), min(latitudes), max(longitudes), max(latitudes))

    return ('http://api.openstreetmap.org/api/0.5/map?bbox='
            + ','.join(map(str, bounds)))
Generate URL for downloading OSM data within a region.

    This function defines a boundary box where the edges touch a circle of
    ``distance`` kilometres in radius.  It is important to note that the box is
    neither a square, nor bounded within the circle.

    The bounding box is strictly a trapezoid whose north and south edges are
    different lengths, which is longer is dependant on whether the box is
    calculated for a location in the Northern or Southern hemisphere.  You will
    get a shorter north edge in the Northern hemisphere, and vice versa.  This
    is simply because we are applying a flat transformation to a spherical
    object, however for all general cases the difference will be negligible.

    Args:
        location (Point): Centre of the region
        distance (int): Boundary distance in kilometres

    Returns:
        str: URL that can be used to fetch the OSM data within ``distance`` of
            ``location``