Spaces:
Sleeping
Sleeping
pareshmishra
commited on
Commit
Β·
ec9afde
1
Parent(s):
089a35b
added colour and list check
Browse files- app/dashboard.py +33 -4
app/dashboard.py
CHANGED
|
@@ -5,18 +5,47 @@ import folium
|
|
| 5 |
from streamlit_folium import folium_static
|
| 6 |
|
| 7 |
st.title("π Earthquake AI Event Map")
|
| 8 |
-
|
| 9 |
-
response = requests.get("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
m = folium.Map(location=[20.5937, 78.9629], zoom_start=4)
|
| 14 |
|
| 15 |
for event in events:
|
|
|
|
| 16 |
lat = event.get("lat", 0)
|
| 17 |
lon = event.get("lon", 0)
|
| 18 |
label = event.get("label", "tremor")
|
| 19 |
ts = event.get("timestamp", "")
|
| 20 |
folium.Marker([lat, lon], tooltip=f"{label} @ {ts}").add_to(m)
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
folium_static(m)
|
|
|
|
| 5 |
from streamlit_folium import folium_static
|
| 6 |
|
| 7 |
st.title("π Earthquake AI Event Map")
|
| 8 |
+
try:
|
| 9 |
+
#response = requests.get("http://localhost:8000/events") for loacl
|
| 10 |
+
response = requests.get("https://overflowing-intuition-production.up.railway.app/events")
|
| 11 |
+
events = response.json()
|
| 12 |
+
except Exception as e:
|
| 13 |
+
st.error("Failed to load event run curl https://your-backend-domain/reset : {e}")
|
| 14 |
+
event=[]
|
| 15 |
|
| 16 |
+
#m = folium.Map(location=[20.5937, 78.9629], zoom_start=4)
|
| 17 |
+
if events:
|
| 18 |
+
first_event = events[0]
|
| 19 |
+
map_center = [first_event.get("lat", 20.59), first_event.get("lon", 78.96)]
|
| 20 |
+
else:
|
| 21 |
+
map_center = [20.5937, 78.9629]
|
| 22 |
+
|
| 23 |
+
m = folium.Map(location=map_center, zoom_start=4)
|
| 24 |
|
|
|
|
| 25 |
|
| 26 |
for event in events:
|
| 27 |
+
if isinstance(event, dict):
|
| 28 |
lat = event.get("lat", 0)
|
| 29 |
lon = event.get("lon", 0)
|
| 30 |
label = event.get("label", "tremor")
|
| 31 |
ts = event.get("timestamp", "")
|
| 32 |
folium.Marker([lat, lon], tooltip=f"{label} @ {ts}").add_to(m)
|
| 33 |
|
| 34 |
+
icon_color = {
|
| 35 |
+
"mainshock": "red",
|
| 36 |
+
"aftershock": "orange",
|
| 37 |
+
"foreshock": "blue",
|
| 38 |
+
"seismic_event": "green",
|
| 39 |
+
"tremor": "gray",
|
| 40 |
+
"impact": "black"
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
color = icon_color.get(label, "purple")
|
| 44 |
+
folium.Marker(
|
| 45 |
+
[lat, lon],
|
| 46 |
+
tooltip=f"{label} @ {ts}",
|
| 47 |
+
icon=folium.Icon(color=color)
|
| 48 |
+
).add_to(m)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
folium_static(m)
|