-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcafes.py
67 lines (54 loc) · 1.71 KB
/
cafes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import overpass
def find_nearby_cafes(latitude, longitude):
api = overpass.API()
query = f"""
node["amenity"="cafe"](around:1000,{latitude},{longitude});
out;
"""
response = api.get(query)
if "features" in response:
return response["features"]
else:
return []
def main():
latitude = 18.5204 # Pune city center latitude
longitude = 73.8567 # Pune city center longitude
cafes = find_nearby_cafes(latitude, longitude)
if cafes:
print("Nearby Cafes:")
for index, cafe in enumerate(cafes, start=1):
name = cafe.get("properties", {}).get("name", "Unnamed Cafe")
print(f"{index}. {name}")
else:
print("No nearby cafes found.")
if __name__ == "__main__":
main()
# """
# import overpass
# def find_nearby_cafes(latitude, longitude):
# api = overpass.API()
# query = f"""
# node["amenity"="cafe"](around:1000,{latitude},{longitude});
# out;
# """
# response = api.get(query)
# return response
# def main():
# latitude = 18.5204 # Pune city center latitude
# longitude = 73.8567 # Pune city center longitude
# response = find_nearby_cafes(latitude, longitude)
# if "elements" in response:
# cafes = response["elements"]
# if cafes:
# print("Nearby Cafes:")
# for index, cafe in enumerate(cafes, start=1):
# name = cafe.get("tags", {}).get("name", "Unnamed Cafe")
# print(f"{index}. {name}")
# else:
# print("No nearby cafes found.")
# else:
# print("Error: Unexpected response from Overpass API")
# print(response)
# if __name__ == "__main__":
# main()
# """