-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFoursquareGeojsonBuilder.py
42 lines (39 loc) · 1.04 KB
/
FoursquareGeojsonBuilder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from GeojsonBuilder import GeojsonBuilder
class FoursquareGeojsonBuilder (GeojsonBuilder):
def build_geojson(self, venues):
features = []
for venue in venues:
properties = {
'source':'Foursquare',
'id':venue['id'],
'name':venue['name'],
'category':venue['categories'][0]['name'],
'specials':venue['specials']['count']
}
try:
properties['address'] = venue['location']['address']
except KeyError:
pass
try:
properties['cross'] = venue['location']['crossStreet']
except KeyError:
pass
try:
properties['contact'] = venue['contact']['formatted']
except KeyError:
pass
try:
properties['hours'] = venue['hours']['status']
except KeyError:
pass
try:
properties['rating'] = venue['rating']
except KeyError:
pass
try:
properties['likes'] = venue['likes']['count']
except KeyError:
pass
feature = self.build_feature(venue['location']['lng'], venue['location']['lat'], properties)
features.append(feature)
return self.build_feature_collection(features)