Deterministic peat fire danger scoring engine and cluster drawer #4

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

What to build

Port the deterministic 0–100 Danger Score engine from data_client.py into a pure, typed TypeScript domain module. Group nearby hotspots into ~2.5 km fire clusters, join them against peat soil depth and KHG status, calculate the danger score (Water Table 35 + Recurrence 30 + Peat Depth 20 + Weather 15), and display an interactive inspection drawer when a cluster or point is selected.

Technical specifications

  1. Target files:

    • src/lib/domain/danger-score.ts: Pure scoring function and TypeScript types.
    • src/lib/domain/__tests__/danger-score.test.ts: Vitest unit tests covering all score brackets.
    • src/lib/gis/spatial-clustering.ts: DBSCAN / grid clustering grouping points within 0.025° (~2.7 km).
    • src/components/drawer/cluster-detail-drawer.tsx: Bottom/side inspection sheet with accessibility support.
    • src/components/drawer/risk-factor-breakdown.tsx: Horizontal telemetry progress bars for the 4 factors.
  2. Deterministic 100-Point Formula:

    • Groundwater Table Depth (TMAT) [0–35 points]:
      • TMAT < -40 cm: Full 35 pts (exceeds legal peat water table dryness threshold).
      • -40 cm <= TMAT <= 0 cm: Linear interpolation round((abs(TMAT) / 40) * 35).
      • TMAT > 0 cm (saturated/flooded): 0 pts.
      • Unknown / distant sensor: fallback 20 pts.
    • Historical Fire Recurrence [0–30 points]:
      • 3+ recurring hotspots in same peat unit: 30 pts (active recurring fire scar).
      • 1-2 recorded hotspots: 15 pts.
      • First-time detection: 0 pts.
    • Peat Depth and Landform [0–20 points]:
      • > 500 cm (Kubah Gambut Ekstrem): 20 pts.
      • 300 - 500 cm (Gambut Sangat Dalam): 17 pts.
      • 100 - 300 cm (Gambut Sedang): 12 pts.
      • < 100 cm (Gambut Dangkal): 6 pts.
      • Non-peat / mineral soil: 0 pts.
    • Weather and Wind [0–15 points]:
      • Wind > 20 km/h and Relative Humidity < 60%: 15 pts.
      • Wind 10 - 20 km/h: 8 pts.
      • Calm wind < 10 km/h or RH > 80%: 2 pts.
    • Classification Brackets:
      • 80 - 100: KRITIS (#dc2626 / red-600)
      • 60 - 79: TINGGI (#ea580c / orange-600)
      • 40 - 59: SEDANG (#d97706 / amber-600)
      • 0 - 39: RENDAH (#16a34a / green-600)
  3. Drawer component:

    • Triggered when clicking any active hotspot cluster.
    • Displays composite badge (e.g. 92 / 100 KRITIS), administrative location (Desa / Kecamatan, Kab, Prov), KHG name, dominant peat depth, and plain-language explanation.
    • Full keyboard accessibility (Escape closes drawer).

Acceptance criteria

  • Vitest unit tests achieve 100% coverage on danger-score.ts boundary calculations.
  • Clicking a hotspot cluster opens the slide-in drawer with complete risk factor telemetry.
  • Map markers dynamically tint to match the computed cluster danger level.

Blocked by

  • Issue 2: RustGIS-compiled static peat and KHG vector tile pipeline.
  • Issue 3: Live SiPongi active hotspots ingestion and clustering.

### What to build Port the deterministic 0–100 Danger Score engine from `data_client.py` into a pure, typed TypeScript domain module. Group nearby hotspots into ~2.5 km fire clusters, join them against peat soil depth and KHG status, calculate the danger score (Water Table 35 + Recurrence 30 + Peat Depth 20 + Weather 15), and display an interactive inspection drawer when a cluster or point is selected. ### Technical specifications 1. **Target files**: - `src/lib/domain/danger-score.ts`: Pure scoring function and TypeScript types. - `src/lib/domain/__tests__/danger-score.test.ts`: Vitest unit tests covering all score brackets. - `src/lib/gis/spatial-clustering.ts`: DBSCAN / grid clustering grouping points within 0.025° (~2.7 km). - `src/components/drawer/cluster-detail-drawer.tsx`: Bottom/side inspection sheet with accessibility support. - `src/components/drawer/risk-factor-breakdown.tsx`: Horizontal telemetry progress bars for the 4 factors. 2. **Deterministic 100-Point Formula**: - **Groundwater Table Depth (TMAT) [0–35 points]**: - `TMAT < -40 cm`: Full `35 pts` (exceeds legal peat water table dryness threshold). - `-40 cm <= TMAT <= 0 cm`: Linear interpolation `round((abs(TMAT) / 40) * 35)`. - `TMAT > 0 cm` (saturated/flooded): `0 pts`. - Unknown / distant sensor: fallback `20 pts`. - **Historical Fire Recurrence [0–30 points]**: - `3+` recurring hotspots in same peat unit: `30 pts` (active recurring fire scar). - `1-2` recorded hotspots: `15 pts`. - First-time detection: `0 pts`. - **Peat Depth and Landform [0–20 points]**: - `> 500 cm` (Kubah Gambut Ekstrem): `20 pts`. - `300 - 500 cm` (Gambut Sangat Dalam): `17 pts`. - `100 - 300 cm` (Gambut Sedang): `12 pts`. - `< 100 cm` (Gambut Dangkal): `6 pts`. - Non-peat / mineral soil: `0 pts`. - **Weather and Wind [0–15 points]**: - Wind `> 20 km/h` and Relative Humidity `< 60%`: `15 pts`. - Wind `10 - 20 km/h`: `8 pts`. - Calm wind `< 10 km/h` or RH `> 80%`: `2 pts`. - **Classification Brackets**: - `80 - 100`: **KRITIS** (`#dc2626` / red-600) - `60 - 79`: **TINGGI** (`#ea580c` / orange-600) - `40 - 59`: **SEDANG** (`#d97706` / amber-600) - `0 - 39`: **RENDAH** (`#16a34a` / green-600) 3. **Drawer component**: - Triggered when clicking any active hotspot cluster. - Displays composite badge (e.g. `92 / 100 KRITIS`), administrative location (`Desa / Kecamatan, Kab, Prov`), KHG name, dominant peat depth, and plain-language explanation. - Full keyboard accessibility (`Escape` closes drawer). ### Acceptance criteria - [x] Vitest unit tests achieve 100% coverage on `danger-score.ts` boundary calculations. - [x] Clicking a hotspot cluster opens the slide-in drawer with complete risk factor telemetry. - [x] Map markers dynamically tint to match the computed cluster danger level. ### Blocked by - Issue 2: RustGIS-compiled static peat and KHG vector tile pipeline. - Issue 3: Live SiPongi active hotspots ingestion and clustering. ---
yuris closed this issue 2026-10-14 20:18:33 +00:00
yuris changed title from Issue 4: Deterministic peat fire danger scoring engine and cluster drawer to Deterministic peat fire danger scoring engine and cluster drawer 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#4
No description provided.