feat(dispatch): nearest firefighter Haversine routing & transit time calculator (firefighters.ts) #61

Closed
opened 2026-10-14 22:28:39 +00:00 by yuris · 0 comments
Owner

This was generated by AI during triage.
Enriched to align with docs/ARCHITECTURE.md §7.3.

What to build

Implement the nearest fire brigade dispatch calculation engine in src/lib/gis/firefighters.ts that computes geodesic distances and estimated terrain transit times from any active fire cluster to the nearest Manggala Agni and BPBD response units.

Technical specifications

  1. Target files:
    • src/lib/gis/firefighters.ts: Haversine distance, speed multipliers, and sorting engine.
    • src/lib/gis/__tests__/firefighters.test.ts: Unit test suite.
  2. Mathematical Model & Transit Multipliers:
    • Geodesic Distance: Great-circle distance using Haversine formula (R = 6371 ext{ km}).
    • Road Transit Speed: 45 ext{ km/h} for primary asphalt roads.
    • Peatland River/Canal Speed: 20 ext{ km/h} for motorized longboat (perahu ketinting).
    • Off-Road Peat Foot Transit: 4 ext{ km/h} for ground crews carrying Mark-3 pumps and hoses.
    • Estimated ETA Formula:
      $$ ext{ETA}{ ext{minutes}} = \left( rac{D{ ext{road}}}{45} + rac{D_{ ext{canal}}}{20} + rac{D_{ ext{foot}}}{4}
      ight) imes 60 + 15 ext{ (mobilization buffer)}
  3. API Interface:
    export function findNearestFireStations(
      fireCoordinates: [number, number],
      limit = 3,
      stations?: FireStation[]
    ): NearestStationResult[]
    

Acceptance criteria

  • Pure functional computation executing in <0.5ms.
  • Returns sorted nearest stations with calculated geodesic distance in km and estimated ETA in minutes.
  • Correctly computes tactical response line coordinates from station to fire centroid.
  • 100% test coverage defending against distance anomalies and zero coordinates.
> *This was generated by AI during triage.* > *Enriched to align with docs/ARCHITECTURE.md §7.3.* ### What to build Implement the nearest fire brigade dispatch calculation engine in `src/lib/gis/firefighters.ts` that computes geodesic distances and estimated terrain transit times from any active fire cluster to the nearest Manggala Agni and BPBD response units. ### Technical specifications 1. **Target files**: - `src/lib/gis/firefighters.ts`: Haversine distance, speed multipliers, and sorting engine. - `src/lib/gis/__tests__/firefighters.test.ts`: Unit test suite. 2. **Mathematical Model & Transit Multipliers**: - Geodesic Distance: Great-circle distance using Haversine formula ($R = 6371 ext{ km}$). - Road Transit Speed: $45 ext{ km/h}$ for primary asphalt roads. - Peatland River/Canal Speed: $20 ext{ km/h}$ for motorized longboat (*perahu ketinting*). - Off-Road Peat Foot Transit: $4 ext{ km/h}$ for ground crews carrying Mark-3 pumps and hoses. - Estimated ETA Formula: $$ ext{ETA}_{ ext{minutes}} = \left( rac{D_{ ext{road}}}{45} + rac{D_{ ext{canal}}}{20} + rac{D_{ ext{foot}}}{4} ight) imes 60 + 15 ext{ (mobilization buffer)}$$ 3. **API Interface**: ```typescript export function findNearestFireStations( fireCoordinates: [number, number], limit = 3, stations?: FireStation[] ): NearestStationResult[] ``` ### Acceptance criteria - [x] Pure functional computation executing in <0.5ms. - [x] Returns sorted nearest stations with calculated geodesic distance in km and estimated ETA in minutes. - [x] Correctly computes tactical response line coordinates from station to fire centroid. - [x] 100% test coverage defending against distance anomalies and zero coordinates.
yuris changed title from Issue 48: [Backend] Nearest firefighter Haversine routing & transit time calculator (firefighters.ts) to [Backend] Nearest firefighter Haversine routing & transit time calculator (firefighters.ts) 2026-10-14 22:31:26 +00:00
yuris changed title from [Backend] Nearest firefighter Haversine routing & transit time calculator (firefighters.ts) to Nearest firefighter Haversine routing & transit time calculator (firefighters.ts) 2026-10-14 22:38:31 +00:00
yuris changed title from Nearest firefighter Haversine routing & transit time calculator (firefighters.ts) to feat(dispatch): nearest firefighter Haversine routing & transit time calculator (firefighters.ts) 2026-10-15 01:27:18 +00:00
yuris closed this issue 2026-10-15 02:51:25 +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#61
No description provided.