Skip to content

Commit 8c5f33f

Browse files
committed
Updated logic.
1 parent 857d46a commit 8c5f33f

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

Diff for: bing/Geocode.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ def GetGeocode(jsondata):
1717
g = {}
1818

1919
# Set name and geocode.
20-
g['name'] = data['resourceSets'][0]['resources'][0]['name']
21-
g['code'] = data['resourceSets'][0]['resources'][0]['geocodePoints'][0]['coordinates']
20+
try:
21+
g['name'] = data['resourceSets'][0]['resources'][0]['name']
22+
g['lat'] = data['resourceSets'][0]['resources'][0]['geocodePoints'][0]['coordinates'][0]
23+
g['long'] = data['resourceSets'][0]['resources'][0]['geocodePoints'][0]['coordinates'][1]
24+
except:
25+
pass
2226

2327
return g
2428

Diff for: bing/README.md

+4-9
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,16 @@ cat data/places.txt
2828
```
2929

3030
```
31-
Alphabet Inc.
31+
The Library of Congress
32+
Mountain View, CA
3233
```
3334

3435
```shell
3536
./driver.py data/places.txt
3637
```
3738

3839
```
39-
```
40-
41-
### Misc
42-
43-
Simple request:
44-
45-
```
46-
http://dev.virtualearth.net/REST/v1/Locations?q=Greenville&maxResults=10&key=BingMapsKey
40+
Library of Congress, DC|38.8876113892|-77.0047073364
41+
Mountain View, CA|37.3896713257|-122.081596375
4742
```
4843

Diff for: bing/data/places.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
The Library of Congress
2-
Alphabet Inc.
2+
Mountain View, CA

Diff for: bing/driver.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def main(argv):
4040
try:
4141
response = GetResponse(apikey, place)
4242
g = GetGeocode(response)
43-
print '{0} | {1}'.format(g['name'], g['code'])
43+
print '{0}|{1}|{2}'.format(g['name'], g['lat'], g['long'])
4444
except Exception:
4545
pass
4646

0 commit comments

Comments
 (0)