Last active
July 21, 2019 23:53
-
-
Save artemrys/4f04a1be5e762ca0dcd46f3ba2d248df to your computer and use it in GitHub Desktop.
Search Starbucks by coords
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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