-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtempCodeRunnerFile.py
More file actions
40 lines (36 loc) · 1.35 KB
/
tempCodeRunnerFile.py
File metadata and controls
40 lines (36 loc) · 1.35 KB
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
import requests
# Fetch OSM data for hotels using Overpass API
def fetch_osm_hotels_data(bbox):
overpass_url = "http://overpass-api.de/api/interpreter"
overpass_query = f"""
[out:json];
(
node["name"="Changi Airport Terminal 3"];
node["tourism"="hotel"]({bbox});
node["highway"="traffic_signals"]({bbox});
node["highway"="crossing"]({bbox});
node["barrier"="toll_booth"]({bbox});
way["highway"~"^(motorway|trunk|primary|secondary|tertiary|residential|living_street|unclassified|service|road|track)$"]({bbox});
);
out body;
>;
out skel qt;
"""
response = requests.get(overpass_url, params={'data': overpass_query})
data = response.json()
return data
# Define bounding box - specify the area you are interested in
lat_min, lon_min, lat_max, lon_max = 1.209, 103.605, 1.474, 104.094
bbox = f"{lat_min},{lon_min},{lat_max},{lon_max}"
# Fetch hotel data
osm_data = fetch_osm_hotels_data(bbox)
# Check if data is fetched successfully
if osm_data:
print("Hotels in the specified bounding box:")
for element in osm_data['elements']:
if element['type'] == 'node' and 'tags' in element and 'name' in element['tags']:
node_id = element['id']
name = element['tags']['name']
print(f"Node ID: {node_id}, Name: {name}")
else:
print("No data fetched.")