Spaces:
Sleeping
Sleeping
rezoom map
Browse files
app.py
CHANGED
@@ -452,23 +452,23 @@ def get_map_from_summary(summary_txt):
|
|
452 |
return None
|
453 |
else:
|
454 |
# cameraimg_df = call_api('http://datamall2.mytransport.sg/ltaodataservice/Traffic-Imagesv2?long=')
|
455 |
-
print('nearest cam')
|
456 |
nearest_cam_df, cameraimg_df= get_nearest_camera((lat,lng), 3)
|
457 |
-
print('ok. nearest fire')
|
458 |
nearest_fire_df = get_firestation_from_latlong((lat,lng), 3)
|
459 |
-
print('ok. nearest hosp')
|
460 |
nearest_hosp_df = get_hospital_from_latlong((lat,lng), 3)
|
461 |
|
462 |
avg_lat = np.mean(cameraimg_df["Latitude"])
|
463 |
avg_lng = np.mean(cameraimg_df["Longitude"])
|
464 |
-
print('ok. folium map')
|
|
|
465 |
map = folium.Map(location=[avg_lat, avg_lng], zoom_start=12)
|
|
|
466 |
folium.Marker(location=[float(lat), float(lng)],
|
467 |
icon=folium.Icon(color='red'),
|
468 |
popup="Incident"
|
469 |
-
).add_to(
|
470 |
-
print('ok')
|
471 |
-
|
472 |
for idx in tqdm(cameraimg_df.index, desc="Processing Traffic Cameras"):
|
473 |
if cameraimg_df["CameraID"][idx] in list(nearest_cam_df["CameraID"]):
|
474 |
print('added nearby camera', nearest_cam_df["Description"][idx])
|
@@ -483,7 +483,7 @@ def get_map_from_summary(summary_txt):
|
|
483 |
|
484 |
folium.Marker(location=[nearest_cam_df["Latitude"][idx], nearest_cam_df["Longitude"][idx]],
|
485 |
icon=folium.Icon(color='blue'),
|
486 |
-
popup=popup).add_to(
|
487 |
else:
|
488 |
# Add marker for the camera with the specified color
|
489 |
folium.Marker(location=[cameraimg_df["Latitude"][idx], cameraimg_df["Longitude"][idx]], icon=folium.Icon(color='gray')).add_to(map)
|
@@ -491,13 +491,13 @@ def get_map_from_summary(summary_txt):
|
|
491 |
for idx in tqdm(nearest_fire_df.index, desc="Processing Fire Stations"):
|
492 |
folium.Marker(location=[nearest_fire_df["lat"][idx], nearest_fire_df["long"][idx]],
|
493 |
icon=folium.Icon(color='orange'),
|
494 |
-
popup=nearest_fire_df["name"][idx]).add_to(
|
495 |
|
496 |
for idx in tqdm(nearest_hosp_df.index, desc="Processing Hospitals"):
|
497 |
folium.Marker(location=[nearest_hosp_df["lat"][idx], nearest_hosp_df["long"][idx]],
|
498 |
icon=folium.Icon(color='green'),
|
499 |
-
popup=nearest_hosp_df["name"][idx]).add_to(
|
500 |
-
|
501 |
return map
|
502 |
|
503 |
async def a_get_map_from_summary(summary_txt, get_num_cameras=3):
|
@@ -519,12 +519,13 @@ async def a_get_map_from_summary(summary_txt, get_num_cameras=3):
|
|
519 |
|
520 |
avg_lat = np.mean(cameraimg_df["Latitude"])
|
521 |
avg_lng = np.mean(cameraimg_df["Longitude"])
|
|
|
522 |
map = folium.Map(location=[avg_lat, avg_lng], zoom_start=12)
|
|
|
523 |
folium.Marker(location=[float(lat), float(lng)],
|
524 |
icon=folium.Icon(color='red'),
|
525 |
popup="Incident"
|
526 |
-
).add_to(
|
527 |
-
|
528 |
for idx in tqdm(cameraimg_df.index, desc="Processing Traffic Cameras"):
|
529 |
if cameraimg_df["CameraID"][idx] in list(nearest_cam_df["CameraID"]):
|
530 |
print('added nearby camera', nearest_cam_df["Description"][idx])
|
@@ -539,7 +540,7 @@ async def a_get_map_from_summary(summary_txt, get_num_cameras=3):
|
|
539 |
|
540 |
folium.Marker(location=[nearest_cam_df["Latitude"][idx], nearest_cam_df["Longitude"][idx]],
|
541 |
icon=folium.Icon(color='blue'),
|
542 |
-
popup=popup).add_to(
|
543 |
else:
|
544 |
# Add marker for the camera with the specified color
|
545 |
folium.Marker(location=[cameraimg_df["Latitude"][idx], cameraimg_df["Longitude"][idx]], icon=folium.Icon(color='gray')).add_to(map)
|
@@ -547,13 +548,13 @@ async def a_get_map_from_summary(summary_txt, get_num_cameras=3):
|
|
547 |
for idx in tqdm(nearest_fire_df.index, desc="Processing Fire Stations"):
|
548 |
folium.Marker(location=[nearest_fire_df["lat"][idx], nearest_fire_df["long"][idx]],
|
549 |
icon=folium.Icon(color='orange'),
|
550 |
-
popup=nearest_fire_df["name"][idx]).add_to(
|
551 |
|
552 |
for idx in tqdm(nearest_hosp_df.index, desc="Processing Hospitals"):
|
553 |
folium.Marker(location=[nearest_hosp_df["lat"][idx], nearest_hosp_df["long"][idx]],
|
554 |
icon=folium.Icon(color='green'),
|
555 |
-
popup=nearest_hosp_df["name"][idx]).add_to(
|
556 |
-
|
557 |
return map
|
558 |
|
559 |
########################## RAG to Recommendations functions ##############################
|
|
|
452 |
return None
|
453 |
else:
|
454 |
# cameraimg_df = call_api('http://datamall2.mytransport.sg/ltaodataservice/Traffic-Imagesv2?long=')
|
455 |
+
# print('nearest cam')
|
456 |
nearest_cam_df, cameraimg_df= get_nearest_camera((lat,lng), 3)
|
457 |
+
# print('ok. nearest fire')
|
458 |
nearest_fire_df = get_firestation_from_latlong((lat,lng), 3)
|
459 |
+
# print('ok. nearest hosp')
|
460 |
nearest_hosp_df = get_hospital_from_latlong((lat,lng), 3)
|
461 |
|
462 |
avg_lat = np.mean(cameraimg_df["Latitude"])
|
463 |
avg_lng = np.mean(cameraimg_df["Longitude"])
|
464 |
+
# print('ok. folium map')
|
465 |
+
|
466 |
map = folium.Map(location=[avg_lat, avg_lng], zoom_start=12)
|
467 |
+
fg = folium.FeatureGroup(show=False).add_to(map)
|
468 |
folium.Marker(location=[float(lat), float(lng)],
|
469 |
icon=folium.Icon(color='red'),
|
470 |
popup="Incident"
|
471 |
+
).add_to(fg)
|
|
|
|
|
472 |
for idx in tqdm(cameraimg_df.index, desc="Processing Traffic Cameras"):
|
473 |
if cameraimg_df["CameraID"][idx] in list(nearest_cam_df["CameraID"]):
|
474 |
print('added nearby camera', nearest_cam_df["Description"][idx])
|
|
|
483 |
|
484 |
folium.Marker(location=[nearest_cam_df["Latitude"][idx], nearest_cam_df["Longitude"][idx]],
|
485 |
icon=folium.Icon(color='blue'),
|
486 |
+
popup=popup).add_to(fg)
|
487 |
else:
|
488 |
# Add marker for the camera with the specified color
|
489 |
folium.Marker(location=[cameraimg_df["Latitude"][idx], cameraimg_df["Longitude"][idx]], icon=folium.Icon(color='gray')).add_to(map)
|
|
|
491 |
for idx in tqdm(nearest_fire_df.index, desc="Processing Fire Stations"):
|
492 |
folium.Marker(location=[nearest_fire_df["lat"][idx], nearest_fire_df["long"][idx]],
|
493 |
icon=folium.Icon(color='orange'),
|
494 |
+
popup=nearest_fire_df["name"][idx]).add_to(fg)
|
495 |
|
496 |
for idx in tqdm(nearest_hosp_df.index, desc="Processing Hospitals"):
|
497 |
folium.Marker(location=[nearest_hosp_df["lat"][idx], nearest_hosp_df["long"][idx]],
|
498 |
icon=folium.Icon(color='green'),
|
499 |
+
popup=nearest_hosp_df["name"][idx]).add_to(fg)
|
500 |
+
map.fit_bounds(fg.get_bounds(), padding=(30, 30))
|
501 |
return map
|
502 |
|
503 |
async def a_get_map_from_summary(summary_txt, get_num_cameras=3):
|
|
|
519 |
|
520 |
avg_lat = np.mean(cameraimg_df["Latitude"])
|
521 |
avg_lng = np.mean(cameraimg_df["Longitude"])
|
522 |
+
|
523 |
map = folium.Map(location=[avg_lat, avg_lng], zoom_start=12)
|
524 |
+
fg = folium.FeatureGroup(show=False).add_to(map)
|
525 |
folium.Marker(location=[float(lat), float(lng)],
|
526 |
icon=folium.Icon(color='red'),
|
527 |
popup="Incident"
|
528 |
+
).add_to(fg)
|
|
|
529 |
for idx in tqdm(cameraimg_df.index, desc="Processing Traffic Cameras"):
|
530 |
if cameraimg_df["CameraID"][idx] in list(nearest_cam_df["CameraID"]):
|
531 |
print('added nearby camera', nearest_cam_df["Description"][idx])
|
|
|
540 |
|
541 |
folium.Marker(location=[nearest_cam_df["Latitude"][idx], nearest_cam_df["Longitude"][idx]],
|
542 |
icon=folium.Icon(color='blue'),
|
543 |
+
popup=popup).add_to(fg)
|
544 |
else:
|
545 |
# Add marker for the camera with the specified color
|
546 |
folium.Marker(location=[cameraimg_df["Latitude"][idx], cameraimg_df["Longitude"][idx]], icon=folium.Icon(color='gray')).add_to(map)
|
|
|
548 |
for idx in tqdm(nearest_fire_df.index, desc="Processing Fire Stations"):
|
549 |
folium.Marker(location=[nearest_fire_df["lat"][idx], nearest_fire_df["long"][idx]],
|
550 |
icon=folium.Icon(color='orange'),
|
551 |
+
popup=nearest_fire_df["name"][idx]).add_to(fg)
|
552 |
|
553 |
for idx in tqdm(nearest_hosp_df.index, desc="Processing Hospitals"):
|
554 |
folium.Marker(location=[nearest_hosp_df["lat"][idx], nearest_hosp_df["long"][idx]],
|
555 |
icon=folium.Icon(color='green'),
|
556 |
+
popup=nearest_hosp_df["name"][idx]).add_to(fg)
|
557 |
+
map.fit_bounds(fg.get_bounds(), padding=(30, 30))
|
558 |
return map
|
559 |
|
560 |
########################## RAG to Recommendations functions ##############################
|