jonathanjordan21 commited on
Commit
8562896
·
verified ·
1 Parent(s): 2e95972

Update utils2.py

Browse files
Files changed (1) hide show
  1. utils2.py +6 -5
utils2.py CHANGED
@@ -88,7 +88,7 @@ from google.type import latlng_pb2
88
  import asyncio
89
 
90
 
91
- async def compute_places_count_with_api_key(api_key, lat, lng, radius, place_type):
92
  try:
93
  client = areainsights_v1.AreaInsightsAsyncClient(
94
  client_options={"api_key": api_key}
@@ -104,8 +104,7 @@ async def compute_places_count_with_api_key(api_key, lat, lng, radius, place_typ
104
 
105
  # 2. Define the place type filter
106
  type_filter = areainsights_v1.TypeFilter(
107
- # included_types=[place_type]
108
- included_types=place
109
  )
110
 
111
  # 3. Assemble the main request body
@@ -137,13 +136,13 @@ def compute_features(candidate_point, api_key, radius=5000):
137
  'category_diversity':0
138
  }
139
 
140
- for i,place in enumerate(GOOGLE_PLACE_TYPE_MAPPING):
141
  total_count = asyncio.run(compute_places_count_with_api_key(
142
  api_key,
143
  lat,
144
  lon,
145
  radius,
146
- place
147
  ))
148
 
149
  features[f'num_{DATASET_COLUMNS[i]}'] = total_count
@@ -164,4 +163,6 @@ def compute_features(candidate_point, api_key, radius=5000):
164
  'category_diversity': sum(bool(v) for v in features.values())
165
  })
166
 
 
 
167
  return features
 
88
  import asyncio
89
 
90
 
91
+ async def compute_places_count_with_api_key(api_key, lat, lng, radius, places):
92
  try:
93
  client = areainsights_v1.AreaInsightsAsyncClient(
94
  client_options={"api_key": api_key}
 
104
 
105
  # 2. Define the place type filter
106
  type_filter = areainsights_v1.TypeFilter(
107
+ included_types=places
 
108
  )
109
 
110
  # 3. Assemble the main request body
 
136
  'category_diversity':0
137
  }
138
 
139
+ for i,places in enumerate(GOOGLE_PLACE_TYPE_MAPPING):
140
  total_count = asyncio.run(compute_places_count_with_api_key(
141
  api_key,
142
  lat,
143
  lon,
144
  radius,
145
+ places
146
  ))
147
 
148
  features[f'num_{DATASET_COLUMNS[i]}'] = total_count
 
163
  'category_diversity': sum(bool(v) for v in features.values())
164
  })
165
 
166
+ print(features)
167
+
168
  return features