Tigernawin commited on
Commit
d29b50b
Β·
verified Β·
1 Parent(s): 311a549

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -22
app.py CHANGED
@@ -93,29 +93,42 @@ if selected_site in SITES:
93
  st.subheader("πŸ“ˆ Tilt vs. Vibration")
94
  st.scatter_chart(site_df[['Tilt Angle (Β°)', 'Vibration (g)']])
95
 
96
- # Map with Red Alerts
97
- st.subheader("πŸ“ Red Alert Pole Locations")
98
- red_df = site_df[site_df['Alert Level'] == 'Red']
99
- if not red_df.empty:
100
- st.pydeck_chart(pdk.Deck(
101
- initial_view_state=pdk.ViewState(
102
- latitude=SITES[selected_site][0],
103
- longitude=SITES[selected_site][1],
104
- zoom=12,
105
- pitch=50
106
- ),
107
- layers=[
108
- pdk.Layer(
109
- 'ScatterplotLayer',
110
- data=red_df,
111
- get_position='[Longitude, Latitude]',
112
- get_color='[255, 0, 0, 160]',
113
- get_radius=100,
114
- )
115
- ]
116
- ))
117
  else:
118
- st.info("No red alerts at this time.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
 
120
  else:
121
  st.warning("Invalid site. Please enter one of: Hyderabad, Gadwal, Kurnool, Ballari")
 
93
  st.subheader("πŸ“ˆ Tilt vs. Vibration")
94
  st.scatter_chart(site_df[['Tilt Angle (Β°)', 'Vibration (g)']])
95
 
96
+ # Map showing all poles by alert level color
97
+ st.subheader("πŸ“ All Pole Locations with Alert Levels")
98
+
99
+ # Map color logic based on Alert Level
100
+ def get_color(alert):
101
+ if alert == 'Green':
102
+ return [0, 255, 0, 160]
103
+ elif alert == 'Yellow':
104
+ return [255, 255, 0, 160]
105
+ elif alert == 'Red':
106
+ return [255, 0, 0, 160]
 
 
 
 
 
 
 
 
 
 
107
  else:
108
+ return [128, 128, 128, 160] # default gray
109
+
110
+ site_df['color'] = site_df['Alert Level'].apply(get_color)
111
+
112
+ st.pydeck_chart(pdk.Deck(
113
+ initial_view_state=pdk.ViewState(
114
+ latitude=SITES[selected_site][0],
115
+ longitude=SITES[selected_site][1],
116
+ zoom=12,
117
+ pitch=50
118
+ ),
119
+ layers=[
120
+ pdk.Layer(
121
+ 'ScatterplotLayer',
122
+ data=site_df,
123
+ get_position='[Longitude, Latitude]',
124
+ get_color='color',
125
+ get_radius=100,
126
+ pickable=True,
127
+ )
128
+ ],
129
+ tooltip={"text": "Pole ID: {Pole ID}\nAlert: {Alert Level}\nHealth: {Health Score}"}
130
+ ))
131
+
132
 
133
  else:
134
  st.warning("Invalid site. Please enter one of: Hyderabad, Gadwal, Kurnool, Ballari")