利用百度geocoding服务解析地址获取位置坐标
    :param address:需要解析的地址
    :return:
977631
def geocode(address):
    
    geocoding = {'s': 'rsv3',
                 'key': key,
                 'city': '全国',
                 'address': address}
    res = requests.get(
        "http://restapi.amap.com/v3/geocode/geo", params=geocoding)
    if res.status_code == 200:
        json = res.json()
        status = json.get('status')
        count = json.get('count')
        if status == '1' and int(count) >= 1:
            geocodes = json.get('geocodes')[0]
            lng = float(geocodes.get('location').split(',')[0])
            lat = float(geocodes.get('location').split(',')[1])
            return [lng, lat]
        else:
            return None
    else:
        return None
123626
def address(self):
        
        self._address, value = self.get_attr_string(self._address, 'address')
        return value
1064553
def google_v3(address):
    
    try:
        g = geocoders.GoogleV3(api_key=settings.EASY_MAPS_GOOGLE_KEY or settings.EASY_MAPS_GOOGLE_MAPS_API_KEY)

        results = g.geocode(smart_str(address), exactly_one=False)
        if results is not None:
            return results[0]

        raise Error("No results found for '%s'" % address)
    except (UnboundLocalError, ValueError, GeocoderServiceError) as e:
        raise Error(e)
652133
def get_address(self):
        
        resource_list = self.get_resource()
        try:
            return [resource['address'] for resource in resource_list]
        except (KeyError, TypeError):
            try:
                if isinstance(resource_list, dict):
                    resource_list = [resource_list]
                return [resource['Address'] for resource in resource_list]
            except (KeyError, TypeError) as exc:
                print(exc)
1072624
def _encodeAddressField(address, smscField=False):
    
    # First, see if this is a number or an alphanumeric string
    toa = 0x80 | 0x00 | 0x01 # Type-of-address start | Unknown type-of-number | ISDN/tel numbering plan
    alphaNumeric = False    
    if address.isalnum():
        # Might just be a local number
        if address.isdigit():
            # Local number
            toa |= 0x20
        else:
            # Alphanumeric address
            toa |= 0x50
            toa &= 0xFE # switch to "unknown" numbering plan
            alphaNumeric = True
    else:
        if address[0] == '+' and address[1:].isdigit():
            # International number
            toa |= 0x10
            # Remove the '+' prefix
            address = address[1:]
        else:
            # Alphanumeric address
            toa |= 0x50
            toa &= 0xFE # switch to "unknown" numbering plan
            alphaNumeric = True
    if  alphaNumeric:
        addressValue = packSeptets(encodeGsm7(address, False))
        addressLen = len(addressValue) * 2        
    else:
        addressValue = encodeSemiOctets(address)
        if smscField:            
            addressLen = len(addressValue) + 1
        else:
            addressLen = len(address)
    result = bytearray()
    result.append(addressLen)
    result.append(toa)
    result.extend(addressValue)
    return result
596930
def _street_addr_from_response(self, match):
        
        # Same caveat as above regarding the ordering of these fields; the
        # documentation is not explicit about the correct ordering for
        # reconstructing a full address, but implies that this is the ordering.
        ordered_fields = ['preQualifier', 'preDirection', 'preType', 'streetName',
                          'suffixType', 'suffixDirection', 'suffixQualifier']
        result = []
        # The address components only contain a from and to address, not the
        # actual number of the address that was matched, so we need to cheat a
        # bit and extract it from the full address string. This is likely to
        # miss some edge cases (hopefully only a few since this is a US-only
        # geocoder).
        addr_num_re = re.match(r'([0-9]+)', match['matchedAddress'])
        if not addr_num_re:  # Give up
            return ''
        result.append(addr_num_re.group(0))
        for field in ordered_fields:
            result.append(match['addressComponents'].get(field, ''))
        if any(result):
            return ' '.join([s for s in result if s])  # Filter out empty strings.
        else:
            return ''
378214
def find_location(address)
      result = geocode(address)
      if result['status'] == 'OK'
        return result['results'][0]['geometry']['location']
      else
        latlon_regexp = /(-?([1-8]?[0-9]\.{1}\d{1,6}|90\.{1}0{1,6})),(-?((([1]?[0-7][0-9]|[1-9]?[0-9])\.{1}\d{1,6})|[1]?[1-8][0]\.{1}0{1,6}))/
        if address =~ latlon_regexp
          location = $&.split(',').map {|e| e.to_f}
          return { "lat" => location[0], "lng" => location[1] }
        else
          return nil
        end
      end
    end
1368666
def bounds(address):
    
    with rasterio.open(address) as src:
        wgs_bounds = transform_bounds(
            *[src.crs, "epsg:4326"] + list(src.bounds), densify_pts=21
        )

    return {"url": address, "bounds": list(wgs_bounds)}
233853
def _address2long(address):
    
    parsed = ipv4.ip2long(address)
    if parsed is None:
        parsed = ipv6.ip2long(address)
    return parsed
1174026
def matches_address(self, address):
        
        if self.address == address:
            return True
        for alias in self.aliases:
            if alias == address:
                return True
        if self._alias_regexp and self._alias_regexp.match(address):
            return True
        return False
1171586
def _validate_address(self, address):
        
        parsed = compat.urlparse(address)
        if not parsed.path:
            raise ValueError("Invalid {} address: {}".format(
                self.__class__.__name__, parsed))
        return parsed
391214
def geocode!(address, options = {})
      response = call_geocoder_service(address, options)
      if response.is_a?(Net::HTTPOK)
        return JSON.parse response.body
      else
        raise ResponseError.new response
      end
    end
319369
def parse_address(self, address, line_number=-1):
        
        return Address(address, self, line_number, self.logger)
168705
public static GeocodingApiRequest geocode(GeoApiContext context, String address) {
    GeocodingApiRequest request = new GeocodingApiRequest(context);
    request.address(address);
    return request;
  }
848179
public function geocode($address)
    {
        $gecode = $this->_url.'address='.urlencode($address);

        if($this->_key){
            $gecode .= '&key='.$this->_key;
        }

        $data = json_decode(file_get_contents($gecode),true);

        $this->_status = $data['status'];

        if ($this->_status === 'OK') {
            $results = $data['results'][0]['geometry']['location'];
            $location = array(
                'longitude' => $results['lng'],
                'latitude' => $results['lat'],
                'results' => $data['results'],
            );

            return $location;
        } else {
            return false;
        }
    }
751429
def _store_account_address(self, address):
        
        address_key = address_prefix + utils.sha3(address)
        self.wb.put(address_key, address)
963558
def _format_structured_address(address):
        
        latitude = address['metadata'].get('latitude')
        longitude = address['metadata'].get('longitude')
        return Location(
            ", ".join((address['delivery_line_1'], address['last_line'])),
            (latitude, longitude) if latitude and longitude else None,
            address
        )