示例#1
0
class Bing(Provider):
    def __init__(self):
        self.geocoder = Bing_geopy(api_key=secrets['api-key']['bing'])

    def raw_location_keys(self) -> Tuple:
        return 'bbox', 'address', 'confidence', 'entityType', 'geocodePoints', 'matchCodes'

    def max_requests(self) -> int:
        return internal_config['max-requests']

    def identifier(self) -> str:
        return 'bing'

    def geocode(self, address) -> Location:
        return self.geocoder.geocode(address,
                                     user_location=Point(longitude=-8,
                                                         latitude=53.5))
示例#2
0
 def __init__(self):
     self.geocoder = Bing_geopy(api_key=secrets['api-key']['bing'])
示例#3
0
__author__ = 'Phansiri'

import csv
from geopy import Bing
geocoder = Bing(api_key='AmfMoSCD5H_hlMzXRoyNh9Gt1pc2tVuyEljxxworN1ghVevEfyZX_Y2Awwk-GST8', timeout=3)


# generate new file and write to it
csvfilewrite = open('address_extented.csv', 'w')
headerNames = ['address', 'city', 'state', 'zip', 'county', 'latitude', 'longitude']
writer = csv.DictWriter(csvfilewrite, fieldnames=headerNames)
writer.writeheader()

# open up csv and for loop through each line
csvfile = open('addresses.csv', 'r')
reader = csv.DictReader(csvfile)
for row in reader:
    loc = geocoder.geocode(row['address'] + ' ' + row['city'] + ', ' + row['state'] + ' ' + row['zip'])
    # write them to the new file
    try:
        print loc
        county = loc.raw['address']['adminDistrict2']
        lat = loc.raw['point']['coordinates'][0]
        long = loc.raw['point']['coordinates'][1]
        writer.writerow({'address': row['address'], 'city': row['city'], 'state': row['state'],
                         'zip': row['zip'], 'county': county, 'latitude': lat, 'longitude': long})
    except ValueError as e:
        print e.message

示例#4
0
文件: models.py 项目: petern08/geotag
 def publish(self):
    geocoder = Bing('AqBGSIDI_RWCMSTeyPJJa59QafcYwL_PyODg6y8EyzJKu6OAg3LH6mVOUjvzkcXI')
    loc = geocoder.geocode(self.address)
    self.ll = loc[1]
    self.created_date = timezone.now()
    self.save()