Skip to content

Instantly share code, notes, and snippets.

@artemrys
Last active July 21, 2019 23:53
Show Gist options
  • Save artemrys/4f04a1be5e762ca0dcd46f3ba2d248df to your computer and use it in GitHub Desktop.
Save artemrys/4f04a1be5e762ca0dcd46f3ba2d248df to your computer and use it in GitHub Desktop.
Search Starbucks by coords
import collections
CountryCityCoords = collections.namedtuple(
"CountryCityCoords", ["country_name", "capital_name", "capital_lat", "capital_lng"]
)
class StarbucksCitySearcher(object):
def __init__(self, e: CountryCityCoords):
self.lat = float(e.capital_lat)
self.lng = float(e.capital_lng)
self.places_ids = set()
def _search(self, lat: float, lng: float):
results = get_starbucks(lat, lng)
for r in results:
self.places_ids.add(r["id"])
def search(self):
for (lat, lng) in get_near_coords(self.lat, self.lng):
self._search(lat, lng)
return len(self.places_ids)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment