-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.py
38 lines (32 loc) · 990 Bytes
/
helpers.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
from geojson import Feature, Point, FeatureCollection
def get_room_location_by_ids(rooms, roomid, siteid):
for room in rooms:
if room["roomid"] == roomid and room["siteid"] == siteid:
return [
room["roomname"],
room["location"]["coordinates"]["lat"],
room["location"]["coordinates"]["lng"],
]
def get_points_for_bookings(bookings, rooms):
points = []
for booking in bookings:
points.append(
get_room_location_by_ids(
rooms,
booking["roomid"],
booking["siteid"]
)
)
return points
def convertToGeoJSON(q):
f = []
for (name, lat, lon) in q:
# print(lat, lon)
lat, lon = map(float, (lat, lon))
f.append(
Feature(
geometry=Point((lon, lat)),
properties={"name": name}
)
)
return str(FeatureCollection(f))