def _get_geocoding(self, key, location):
        """Lookup the Google geocoding API information for `key`"""

        url = self._location_query_base % quote_plus(key)
        if self.api_key:
            url += "&key=%s" % self.api_key
        data = self._read_from_url(url)
        response = json.loads(data)
        if response["status"] == "OK":
            formatted_address = response["results"][0]["formatted_address"]
            pos = formatted_address.find(",")
            if pos == -1:
                location.name = formatted_address
                location.region = ""
            else:
                location.name = formatted_address[:pos].strip()
                location.region = formatted_address[pos + 1 :].strip()

            geo_location = response["results"][0]["geometry"]["location"]
            location.latitude = float(geo_location["lat"])
            location.longitude = float(geo_location["lng"])
        else:
            raise AstralError("GoogleGeocoder: Unable to locate %s. Server Response=%s" %
                              (key, response["status"]))
def _get_geocoding ( self , key , location ) : url = self . _location_query_base % quote_plus ( key ) if self . api_key : url += "&key=%s" % self . api_key data = self . _read_from_url ( url ) response = json . loads ( data ) if response [ "status" ] == "OK" : formatted_address = response [ "results" ] [ 0 ] [ "formatted_address" ] pos = formatted_address . find ( "," ) if pos == - 1 : location . name = formatted_address location . region = "" else : location . name = formatted_address [ : pos ] . strip ( ) location . region = formatted_address [ pos + 1 : ] . strip ( ) geo_location = response [ "results" ] [ 0 ] [ "geometry" ] [ "location" ] location . latitude = float ( geo_location [ "lat" ] ) location . longitude = float ( geo_location [ "lng" ] ) else : raise AstralError ( "GoogleGeocoder: Unable to locate %s. Server Response=%s" % ( key , response [ "status" ] ) )
Lookup the Google geocoding API information for `key`