Пример #1
0
 def augment_entity(self, entity):
     search_result = geocode.lookup_place(entity.name, latlng_dict=entity.latlng.to_json_obj())
     if search_result:
         place_result = google_places.lookup_place_by_reference(search_result.get_reference())
         google_place_entity = place_result.to_entity()
         google_place_entity.update(entity)
         return google_place_entity
     else:
         return entity.copy()
Пример #2
0
 def lookup_google_place(self):
     if not hasattr(self, '_google_place'):
         city = self.get_city()
         query = '%s %s' % (self.get_entity_name(), city)
         place_result = geocode.lookup_place(query)
         if place_result:
             place = google_places.lookup_place_by_reference(place_result.get_reference())
             self._google_place = place.to_entity() if place else None
         else:
             self._google_place = None
     return self._google_place
 def lookup_entities(self, entity_datas):
     entities = []
     address_context = self.get_address_context()
     for entity_data in entity_datas:
         if entity_data.address and self.use_address:
             query = '%s, %s, %s' % (entity_data.name, entity_data.address, address_context)
         else:
             query = '%s, %s' % (entity_data.name, address_context)
         place_result = geocode.lookup_place(query)
         if not place_result or not place_result.get_reference():
             print 'Could not find a place for entity data: %s' % entity_data.__dict__
             continue
         place = google_places.lookup_place_by_reference(place_result.get_reference())
         entities.append(place.to_entity())
     return self.process_entities(entities)