Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
import folium
|
3 |
-
from folium.plugins import MarkerCluster
|
4 |
import googlemaps
|
5 |
from datetime import datetime
|
6 |
import os
|
@@ -25,25 +24,6 @@ def render_folium_map(coords):
|
|
25 |
folium.PolyLine(coords, color="blue", weight=2.5, opacity=1).add_to(m)
|
26 |
return m
|
27 |
|
28 |
-
# Function to add medical center paths and annotate distance
|
29 |
-
def add_medical_center_paths(m, source, med_centers):
|
30 |
-
for name, lat, lon, specialty, city in med_centers:
|
31 |
-
_, coords = get_directions_and_coords(source, (lat, lon))
|
32 |
-
if coords:
|
33 |
-
folium.PolyLine(coords, color="red", weight=2.5, opacity=1).add_to(m)
|
34 |
-
folium.Marker([lat, lon], popup=name).add_to(m)
|
35 |
-
distance_info = gmaps.distance_matrix(source, (lat, lon), mode='driving')
|
36 |
-
distance = distance_info['rows'][0]['elements'][0]['distance']['text']
|
37 |
-
folium.PolyLine(coords, color='red').add_to(m)
|
38 |
-
folium.map.Marker(
|
39 |
-
[coords[-1][0], coords[-1][1]],
|
40 |
-
icon=folium.DivIcon(
|
41 |
-
icon_size=(150, 36),
|
42 |
-
icon_anchor=(0, 0),
|
43 |
-
html=f'<div style="font-size: 10pt; color : red;">{distance}</div>',
|
44 |
-
)
|
45 |
-
).add_to(m)
|
46 |
-
|
47 |
# Function to search nearby medical centers using Google Places API
|
48 |
def search_medical_centers(query, location, radius=10000):
|
49 |
# Search for places like hospitals or medical centers nearby
|
@@ -70,7 +50,7 @@ def get_route_and_medical_centers(source_location, destination_location, medical
|
|
70 |
location_coords = geocode_result[0]['geometry']['location']
|
71 |
lat, lon = location_coords['lat'], location_coords['lng']
|
72 |
|
73 |
-
# Fetch nearby medical centers
|
74 |
medical_centers = search_medical_centers(medical_center_query, (lat, lon))
|
75 |
|
76 |
if medical_centers:
|
|
|
1 |
import gradio as gr
|
2 |
import folium
|
|
|
3 |
import googlemaps
|
4 |
from datetime import datetime
|
5 |
import os
|
|
|
24 |
folium.PolyLine(coords, color="blue", weight=2.5, opacity=1).add_to(m)
|
25 |
return m
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
# Function to search nearby medical centers using Google Places API
|
28 |
def search_medical_centers(query, location, radius=10000):
|
29 |
# Search for places like hospitals or medical centers nearby
|
|
|
50 |
location_coords = geocode_result[0]['geometry']['location']
|
51 |
lat, lon = location_coords['lat'], location_coords['lng']
|
52 |
|
53 |
+
# Fetch nearby medical centers
|
54 |
medical_centers = search_medical_centers(medical_center_query, (lat, lon))
|
55 |
|
56 |
if medical_centers:
|