KJ commited on
Commit ·
2af3d93
1
Parent(s): a575f4e
adding telemtry
Browse files
app.py
CHANGED
|
@@ -73,7 +73,12 @@ else:
|
|
| 73 |
# --- Load GPS Data ---
|
| 74 |
def load_gps_data(from_ts, to_ts):
|
| 75 |
try:
|
| 76 |
-
query = text("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
df = pd.read_sql(query, engine, params={"from_ts": from_ts, "to_ts": to_ts})
|
| 78 |
return df
|
| 79 |
except Exception as e:
|
|
@@ -88,7 +93,6 @@ if start_ts and end_ts:
|
|
| 88 |
if not gps_data.empty:
|
| 89 |
points = gps_data[["latitude", "longitude"]].to_dict(orient="records")
|
| 90 |
js_points = ",\n".join([f"{{ lat: {p['latitude']}, lng: {p['longitude']} }}" for p in points])
|
| 91 |
-
center = points[0]
|
| 92 |
|
| 93 |
st.components.v1.html(f"""
|
| 94 |
<div id=\"map\" style=\"height: 80vh; width: 100%;\"></div>
|
|
@@ -185,5 +189,10 @@ if not gps_data.empty:
|
|
| 185 |
window.onload = initMap;
|
| 186 |
</script>
|
| 187 |
""", height=750)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
else:
|
| 189 |
-
st.info("No GPS data available for selected time frame.")
|
|
|
|
| 73 |
# --- Load GPS Data ---
|
| 74 |
def load_gps_data(from_ts, to_ts):
|
| 75 |
try:
|
| 76 |
+
query = text("""
|
| 77 |
+
SELECT latitude, longitude, speed_kph, rpm, fuel_level, battery_voltage, ignition, device_id
|
| 78 |
+
FROM gps_points
|
| 79 |
+
WHERE timestamp BETWEEN :from_ts AND :to_ts
|
| 80 |
+
ORDER BY timestamp
|
| 81 |
+
""")
|
| 82 |
df = pd.read_sql(query, engine, params={"from_ts": from_ts, "to_ts": to_ts})
|
| 83 |
return df
|
| 84 |
except Exception as e:
|
|
|
|
| 93 |
if not gps_data.empty:
|
| 94 |
points = gps_data[["latitude", "longitude"]].to_dict(orient="records")
|
| 95 |
js_points = ",\n".join([f"{{ lat: {p['latitude']}, lng: {p['longitude']} }}" for p in points])
|
|
|
|
| 96 |
|
| 97 |
st.components.v1.html(f"""
|
| 98 |
<div id=\"map\" style=\"height: 80vh; width: 100%;\"></div>
|
|
|
|
| 189 |
window.onload = initMap;
|
| 190 |
</script>
|
| 191 |
""", height=750)
|
| 192 |
+
|
| 193 |
+
st.subheader("📊 Telemetry Data")
|
| 194 |
+
st.dataframe(gps_data[[
|
| 195 |
+
"device_id", "speed_kph", "rpm", "fuel_level", "battery_voltage", "ignition"
|
| 196 |
+
]])
|
| 197 |
else:
|
| 198 |
+
st.info("No GPS data available for selected time frame.")
|