fix: restore station telemetry and make river flow visualization data-driven
Station selection showed no history since 21ca844: Chart.js v4 datasets
had parsing:false with plain number arrays, drawing empty axes. Remove
the flag so the chart parses values again.
Backend hardening for the same flow:
- /measurements/history/{code} no longer 503s on non-Postgres configs;
it falls back to the configured adapter (reversed to ascending order)
- DB_TYPE defaults to postgresql when POSTGRES_CONNECTION_STRING is set
and DB_TYPE is unset, so the .env psql wins over the sqlite default
- zero readings (0.0) are no longer coerced to None, which would fail
MeasurementResponse validation and 500 /measurements/latest
Map visualization:
- river segments are now colored, widened and dash-speed-animated by
the discharge at the nearest gauge (same scale as the marker legend)
- fix z-order bug that drew the animated flow line behind its casing
- legend entries for river lines, reduced-motion fallback
River geometry: rebuild ping-river-network.geojson from Overpass
(110 -> 202 features), restoring missing Ping mainstem reaches through
the Bhumibol reservoir and the Tak-Kamphaeng Phet braided section
(unnamed waterway=river ways in OSM), with short synthetic connectors
(connector: true) bridging remaining sub-8 km holes.
This commit is contained in:
@@ -519,9 +519,9 @@ class SQLAdapter(DatabaseAdapter):
|
||||
"station_code": row[1],
|
||||
"station_name_en": row[2],
|
||||
"station_name_th": row[3],
|
||||
"water_level": float(row[4]) if row[4] else None,
|
||||
"discharge": float(row[5]) if row[5] else None,
|
||||
"discharge_percent": float(row[6]) if row[6] else None,
|
||||
"water_level": float(row[4]) if row[4] is not None else None,
|
||||
"discharge": float(row[5]) if row[5] is not None else None,
|
||||
"discharge_percent": float(row[6]) if row[6] is not None else None,
|
||||
"status": row[7],
|
||||
}
|
||||
)
|
||||
@@ -573,9 +573,9 @@ class SQLAdapter(DatabaseAdapter):
|
||||
"station_code": row[1],
|
||||
"station_name_en": row[2],
|
||||
"station_name_th": row[3],
|
||||
"water_level": float(row[4]) if row[4] else None,
|
||||
"discharge": float(row[5]) if row[5] else None,
|
||||
"discharge_percent": float(row[6]) if row[6] else None,
|
||||
"water_level": float(row[4]) if row[4] is not None else None,
|
||||
"discharge": float(row[5]) if row[5] is not None else None,
|
||||
"discharge_percent": float(row[6]) if row[6] is not None else None,
|
||||
"status": row[7],
|
||||
}
|
||||
)
|
||||
@@ -618,9 +618,9 @@ class SQLAdapter(DatabaseAdapter):
|
||||
"station_id": row[1],
|
||||
"station_code": row[2] or f"Station_{row[1]}",
|
||||
"station_name_th": row[3] or f"Station {row[1]}",
|
||||
"water_level": float(row[4]) if row[4] else None,
|
||||
"discharge": float(row[5]) if row[5] else None,
|
||||
"discharge_percent": float(row[6]) if row[6] else None,
|
||||
"water_level": float(row[4]) if row[4] is not None else None,
|
||||
"discharge": float(row[5]) if row[5] is not None else None,
|
||||
"discharge_percent": float(row[6]) if row[6] is not None else None,
|
||||
"status": row[7],
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user