Live peat groundwater (TMAT) station overlay and risk factor integration #5

Closed
opened 2026-10-14 18:24:06 +00:00 by yuris · 0 comments
Owner

What to build

Create an API route and UI overlay for real-time peatland groundwater table depth (TMAT / Tinggi Muka Air Tanah) monitoring stations. Match each fire cluster to the nearest TMAT sensor, enforce the -40 cm critical dryness threshold, and render station markers on the map.

Technical specifications

  1. Target files:

    • src/app/api/tmat/route.ts: Telemetry proxy endpoint delivering normalized sensor stations.
    • src/types/tmat.ts: TypeScript interfaces for sensor telemetry and thresholds.
    • src/lib/services/tmat.ts: Upstream sensor ingest with geographic KD-Tree index.
    • src/components/map/layers/tmat-layer.tsx: MapLibre circle/symbol layer for sensor locations.
    • src/components/map/popups/tmat-popup.tsx: Sensor details popup showing 7-day trend sparkline.
  2. Telemetry schema:

    interface TmatStation {
      id: string;
      code: string;
      name: string;
      province: string;
      coordinates: [longitude: number, latitude: number];
      water_level_cm: number; // e.g. -48.2
      battery_volts?: number;
      last_reading_at: string;
      status: "kering_kritis" | "waspada" | "normal"; // < -40 cm = kritis, -40 to -20 cm = waspada, > -20 cm = normal
    }
    
  3. Spatial indexing & danger score integration:

    • Ingest station list into a flat spatial 2D index (KDBush / KD-Tree) for sub-millisecond nearest neighbor queries.
    • If distance to closest station is <= 50 km, inject water_level_cm into Issue 4's danger scoring function.
    • If distance > 50 km, flag sensor_fallback: true in cluster metadata.
  4. Map visualization:

    • Normal stations (> -20 cm): Blue dot (#38bdf8)
    • Waspada stations (-40 to -20 cm): Yellow dot (#facc15)
    • Kritis / Kering stations (< -40 cm): Pulsing red/white beacon (#ef4444) with animated radius ring.

Acceptance criteria

  • GET /api/tmat returns verified station array with numeric water levels.
  • MapLibre displays TMAT stations with status-coded markers and toggleable visibility.
  • The danger scoring engine consumes the nearest TMAT sensor value for nearby fire clusters.
  • Clicking a station shows water level in cm relative to surface and date of last sync.

Blocked by

  • Issue 4: Deterministic peat fire danger scoring engine and cluster drawer.

### What to build Create an API route and UI overlay for real-time peatland groundwater table depth (TMAT / Tinggi Muka Air Tanah) monitoring stations. Match each fire cluster to the nearest TMAT sensor, enforce the -40 cm critical dryness threshold, and render station markers on the map. ### Technical specifications 1. **Target files**: - `src/app/api/tmat/route.ts`: Telemetry proxy endpoint delivering normalized sensor stations. - `src/types/tmat.ts`: TypeScript interfaces for sensor telemetry and thresholds. - `src/lib/services/tmat.ts`: Upstream sensor ingest with geographic KD-Tree index. - `src/components/map/layers/tmat-layer.tsx`: MapLibre circle/symbol layer for sensor locations. - `src/components/map/popups/tmat-popup.tsx`: Sensor details popup showing 7-day trend sparkline. 2. **Telemetry schema**: ```ts interface TmatStation { id: string; code: string; name: string; province: string; coordinates: [longitude: number, latitude: number]; water_level_cm: number; // e.g. -48.2 battery_volts?: number; last_reading_at: string; status: "kering_kritis" | "waspada" | "normal"; // < -40 cm = kritis, -40 to -20 cm = waspada, > -20 cm = normal } ``` 3. **Spatial indexing & danger score integration**: - Ingest station list into a flat spatial 2D index (KDBush / KD-Tree) for sub-millisecond nearest neighbor queries. - If distance to closest station is `<= 50 km`, inject `water_level_cm` into Issue 4's danger scoring function. - If distance `> 50 km`, flag `sensor_fallback: true` in cluster metadata. 4. **Map visualization**: - Normal stations (`> -20 cm`): Blue dot (`#38bdf8`) - Waspada stations (`-40 to -20 cm`): Yellow dot (`#facc15`) - Kritis / Kering stations (`< -40 cm`): Pulsing red/white beacon (`#ef4444`) with animated radius ring. ### Acceptance criteria - [x] `GET /api/tmat` returns verified station array with numeric water levels. - [x] MapLibre displays TMAT stations with status-coded markers and toggleable visibility. - [x] The danger scoring engine consumes the nearest TMAT sensor value for nearby fire clusters. - [x] Clicking a station shows water level in cm relative to surface and date of last sync. ### Blocked by - Issue 4: Deterministic peat fire danger scoring engine and cluster drawer. ---
yuris closed this issue 2026-10-14 20:37:22 +00:00
yuris changed title from Issue 5: Live peat groundwater (TMAT) station overlay and risk factor integration to Live peat groundwater (TMAT) station overlay and risk factor integration 2026-10-14 22:31:31 +00:00
Sign in to join this conversation.
No labels
backend
frontend
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
yuris/titik-gambut-next#5
No description provided.