feat(tmat): live peat groundwater station overlay and risk factor integration (Issue 5) #15
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/issue-5-tmat-groundwater"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implements Issue 5: Live peat groundwater (TMAT) station overlay and risk factor integration.
src/types/tmat.ts: ModeledTmatStation,TmatStatus, and telemetry interfaces.src/lib/services/tmat.ts: Dual ingest from KLHK SiPongi konsesi and masyarakat/SIPALAGA stations with numeric water level normalization, 30-minute caching, and 2D geographic KD-Tree spatial index for sub-millisecond nearest neighbor queries.src/app/api/tmat/route.ts: API route returning verified station array (556 live stations) or nearest station lookup via?lat=&lon=&threshold=50.src/components/map/layers/tmat-layer.tsx: Status-coded MapLibre markers (cyan for normal > -20 cm, amber for waspada -40 to -20 cm, red pulsing beacon for kering kritis < -40 cm) and popup display on click.src/components/map/popups/tmat-popup.tsx: Sensor details popup showing water level depth in cm, status badge, location, and sync time.src/lib/gis/spatial-clustering.ts&src/components/drawer/cluster-detail-drawer.tsx: Ingested nearest TMAT sensor telemetry (within 50 km cutoff) into danger score calculation and drawer inspection view.tmat.test.tspassing.Closes #5
Review: Issue 5 - Live peat groundwater (TMAT) station overlay and risk factor integration
Verdict: APPROVE
Five-Axis Review Summary
1. Correctness
water_level_cmvalues, normalized coordinates, and accurate status classifications (kering_kritisfor< -40\text{ cm},waspadafor-40\text{ to } -20\text{ cm},normalfor> -20\text{ cm}).TmatSpatialIndex) verified. Sub-millisecond lookup accurately finds nearest sensors with\le 50\text{ km}cutoff constraint.#38bdf8, yellow#facc15, pulsing red beacon#ef4444for critical dryness). Clicking stations displaysTmatPopupwith water level, last sync time, and station metadata.2. Readability & Simplicity
src/types/tmat.ts.src/lib/services/tmat.ts.LayerTogglespanel.3. Architecture
TmatSpatialIndexis cached with a 30-minute TTL, avoiding redundant upstream requests while preserving live telemetry./api/tmatsupports both bulk GeoJSON station delivery and targeted?lat=&lon=&threshold=nearest-neighbor lookups.4. Security & Hardening
NaN.5. Performance
Ponytail Audit
Verification
pnpm test: All 25 unit tests passed (including TMAT spatial index & distance tests).vp check: Clean across 98 files (0 errors, 0 warnings).next build: Standalone production build compiled in 9.1s with/api/tmatdynamic route registered.