File tree 4 files changed +12
-13
lines changed
4 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,12 @@ def GetGeocode(jsondata):
17
17
g = {}
18
18
19
19
# 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
22
26
23
27
return g
24
28
Original file line number Diff line number Diff line change @@ -28,21 +28,16 @@ cat data/places.txt
28
28
```
29
29
30
30
```
31
- Alphabet Inc.
31
+ The Library of Congress
32
+ Mountain View, CA
32
33
```
33
34
34
35
``` shell
35
36
./driver.py data/places.txt
36
37
```
37
38
38
39
```
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
47
42
```
48
43
Original file line number Diff line number Diff line change 1
1
The Library of Congress
2
- Alphabet Inc.
2
+ Mountain View, CA
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ def main(argv):
40
40
try :
41
41
response = GetResponse (apikey , place )
42
42
g = GetGeocode (response )
43
- print '{0} | {1}' .format (g ['name' ], g ['code ' ])
43
+ print '{0}| {1}|{2} ' .format (g ['name' ], g ['lat' ], g [ 'long ' ])
44
44
except Exception :
45
45
pass
46
46
You can’t perform that action at this time.
0 commit comments