diff options
author | clarkzjw <[email protected]> | 2023-02-21 01:43:49 -0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2023-02-21 01:43:49 -0800 |
commit | 92c0139e067a7f40ef686714f6edaa8bb8970db7 (patch) | |
tree | 78d9eee925102930fff52d22a2f5c0d5824df4d4 /foursquare/query_poi.py | |
parent | 88ad58c3d3412162ffdeb96f49b789e7976cad07 (diff) | |
parent | 1046a4dd835468ee4855d70ca0a5e6dc6f79cb32 (diff) | |
download | swarm2fediverse-92c0139e067a7f40ef686714f6edaa8bb8970db7.tar.gz |
Merge branch 'feature/poi_photo'
allow users to upload up to 4 photos when checking in
Diffstat (limited to 'foursquare/query_poi.py')
-rw-r--r-- | foursquare/query_poi.py | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/foursquare/query_poi.py b/foursquare/query_poi.py deleted file mode 100644 index e2d5625..0000000 --- a/foursquare/query_poi.py +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | import json | ||
2 | |||
3 | import requests | ||
4 | |||
5 | from config import FSQ_API_KEY | ||
6 | from dbstore.dbm_store import store_loc | ||
7 | |||
8 | POI_API_ENDPOINT = "https://api.foursquare.com/v3/places/nearby?ll={}%2C{}" | ||
9 | OSM_ENDPOINT = "https://www.openstreetmap.org/?mlat={}&mlon={}&zoom=15&layers=M" | ||
10 | |||
11 | |||
12 | def query_poi(latitude, longitude): | ||
13 | locations = list() | ||
14 | |||
15 | url = POI_API_ENDPOINT.format(latitude, longitude) | ||
16 | headers = { | ||
17 | "accept": "application/json", | ||
18 | "Authorization": FSQ_API_KEY | ||
19 | } | ||
20 | |||
21 | response = requests.get(url, headers=headers) | ||
22 | |||
23 | for poi in json.loads(response.text)["results"]: | ||
24 | loc = { | ||
25 | "fsq_id": poi["fsq_id"], | ||
26 | "name": poi["name"], | ||
27 | "locality": poi["location"]["locality"], | ||
28 | "region": poi["location"]["region"], | ||
29 | "latitude": poi["geocodes"]["main"]["latitude"], | ||
30 | "longitude": poi["geocodes"]["main"]["longitude"], | ||
31 | "osm_url": OSM_ENDPOINT.format(poi["geocodes"]["main"]["latitude"], poi["geocodes"]["main"]["longitude"]) | ||
32 | } | ||
33 | locations.append(loc) | ||
34 | store_loc(loc) | ||
35 | |||
36 | return locations | ||