Exemplo n.º 1
0
def reverse_geocode(point):
    try:
        g = Google(settings.GOOGLE_MAPS_API_KEY)
        (new_place,new_point) = g.reverse((point.y, point.x))
        return new_place
    except:
        pass
    return ""   
Exemplo n.º 2
0
 def save(self,**kwargs):
     if not self.location:
         address = u'%s %s' % (self.city, self.address)
         address=address.encode("utf-8")
         geocoder=Google()
         try:
             _, latlon = geocoder.geocode(address)
         except ("Geocodowanie blad", GQueryError, ValueError):
             pass
         else:
             point = "POINT(%s %s)" % (latlon[1], latlon[0])
             self.location = geos.fromstr(point)
     super(Place, self).save()
Exemplo n.º 3
0
 def setUp(self):
     from geopy.geocoders.google import Google
     self.geocoder = Google()
Exemplo n.º 4
0
def geocode(name, exactly_one=False):
    try:
        g = Google(settings.GOOGLE_MAPS_API_KEY)
        return list(g.geocode(name, exactly_one=exactly_one))
    except:
        logging.error("Could not get reverse geocode for {{point.y}}-{{point.x}}")