Ejemplo n.º 1
0
def woeid(location, use_cache=True):
    """
    Get the Yahoo! WOEID for a location.
    """
    if use_cache:
        woeid = cache.perma_get(location, 'woeid')
        if woeid is not None:
            return int(woeid)
    data = get_info_on_location(location)
    woeid = int(data['woeid'])
    if use_cache:
        cache.perma_set(location, woeid, 'woeid')
    return woeid
Ejemplo n.º 2
0
def coord(location, use_cache=True):
    """
    Get the latitude and longitude for a location.
    """
    if use_cache:
        coord = cache.perma_get(location, 'coord')
        if coord is not None:
            return GeoLocation(*map(float, coord.split(',')))
    data = get_info_on_location(location)
    latitude  = data['centroid']['latitude']
    longitude = data['centroid']['longitude']
    if use_cache:
        cache.perma_set(location, '{0},{1}'.format(latitude, longitude), 'coord')
    return GeoLocation(float(latitude), float(longitude))