def run(place, listen='', usa=False, limit=1, nearby=0): gc = sgeo.GeoCoder(listen=listen, usa_only=usa) center = gc.get_locations(place, limit=limit) hits = gc.get_hits() print 'Found the following locations:' print hits if center and nearby: query = '%s %s' % (center.get('state_code'), center.get('country_code')) hits = sgeo.get_nearby_places(center.lat, center.lon, query, exclude=True, limit=nearby) print 'And %s nearby places to "%s, %s" on geonames:' % (hits.total, center.place, center.state_code) print hits
def get_nearby(place, usa_only=False, offset=0, limit=10): gc = sgeo.GeoCoder(usa_only=usa_only) center = gc.get_locations(place) center_hits = gc.get_hits() if center: query = '%s %s' % (center.get('state_code'), center.get('country_code')) nearby_hits = sgeo.get_nearby_places(center.lat, center.lon, query, exclude=True, offset=offset, limit=limit) else: nearby_hits = fsphinx.Hits() add_to_recent_queries(place) return place, center_hits, nearby_hits
def run(place, listen='', usa=False, limit=1, nearby=0): gc = sgeo.GeoCoder(listen=listen, usa_only=usa) center = gc.get_locations(place, limit=limit) hits = gc.get_hits() print 'Found the following locations:' print hits if center and nearby: query = '%s %s' % (center.get('state_code'), center.get('country_code')) hits = sgeo.get_nearby_places(center.lat, center.lon, query, exclude=True, limit=nearby) print 'And %s nearby places to "%s, %s" on geonames:' % ( hits.total, center.place, center.state_code) print hits