aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'foursquare')
-rw-r--r--foursquare/poi.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/foursquare/poi.py b/foursquare/poi.py
index 39895b7..5e31dc8 100644
--- a/foursquare/poi.py
+++ b/foursquare/poi.py
@@ -4,6 +4,7 @@ from config import FSQ_API_KEY
4from dbstore.peewee_store import create_or_update_poi 4from dbstore.peewee_store import create_or_update_poi
5 5
6POI_API_ENDPOINT = "https://api.foursquare.com/v3/places/nearby?ll={}%2C{}&limit=10" 6POI_API_ENDPOINT = "https://api.foursquare.com/v3/places/nearby?ll={}%2C{}&limit=10"
7POI_DETAIL_ENDPOINT = "https://api.foursquare.com/v3/places/{}"
7POI_SEARCH_API_ENDPOINT = "https://api.foursquare.com/v3/places/search?query={}&ll={}%2C{}&radius=2000&limit=10" 8POI_SEARCH_API_ENDPOINT = "https://api.foursquare.com/v3/places/search?query={}&ll={}%2C{}&radius=2000&limit=10"
8POI_PHOTO_ENDPOINT = "https://api.foursquare.com/v3/places/{}/photos?sort=POPULAR&limit=10" 9POI_PHOTO_ENDPOINT = "https://api.foursquare.com/v3/places/{}/photos?sort=POPULAR&limit=10"
9OSM_ENDPOINT = "https://www.openstreetmap.org/?mlat={}&mlon={}&zoom=15&layers=M" 10OSM_ENDPOINT = "https://www.openstreetmap.org/?mlat={}&mlon={}&zoom=15&layers=M"
@@ -35,6 +36,26 @@ def query_poi(search, latitude, longitude):
35 return locations 36 return locations
36 37
37 38
39def query_poi_by_fsq_id(fsq_id):
40 url = POI_DETAIL_ENDPOINT.format(fsq_id)
41 response = requests.get(url, headers=headers)
42
43 poi = json.loads(response.text)
44
45 loc = {
46 "fsq_id": fsq_id,
47 "name": poi["name"],
48 "locality": poi["location"]["locality"] if "locality" in poi["location"] else "",
49 "region": poi["location"]["region"] if "region" in poi["location"] else "",
50 "latitude": poi["geocodes"]["main"]["latitude"],
51 "longitude": poi["geocodes"]["main"]["longitude"],
52 "osm_url": OSM_ENDPOINT.format(poi["geocodes"]["main"]["latitude"], poi["geocodes"]["main"]["longitude"])
53 }
54 create_or_update_poi(loc)
55
56 return loc
57
58
38def get_poi_top_photo(fsq_id): 59def get_poi_top_photo(fsq_id):
39 url = POI_PHOTO_ENDPOINT.format(fsq_id) 60 url = POI_PHOTO_ENDPOINT.format(fsq_id)
40 response = requests.get(url, headers=headers) 61 response = requests.get(url, headers=headers)
Powered by cgit v1.2.3 (git 2.41.0)