Infrastructure medium complexity Shared Component backend
0
Dependencies
0
Dependents
1
Entities
0
Integrations

Description

Stateless utility that computes the great-circle distance between two geographic coordinate pairs using the Haversine formula. Returns distances in both kilometres and miles. Used exclusively by the matching service and ranking engine; has no external dependencies.

Feature: Assignment Matching by Geography

haversine-distance-calculator

Sources & reasoning

Line 99 directly ties geographic visualization to matching and assignment dispatch (oppdragstildeling), providing the provenance for this feature as a distinct matching capability beyond simple map display. Line 358 places it in Fase 3, normalizing to v1.1. The blueprint lists this feature under Geographic Map View at [v1.1]. Kept as a separate feature from peer-mentor-map because matching logic and the dispatch integration are distinct from rendering the map layer.

Responsibilities

  • Compute great-circle distance from two coordinate pairs
  • Return result in configurable units (km / miles)
  • Validate coordinate range before computation
  • Handle poles and antimeridian edge cases without NaN output

Interfaces

calculate(from: Coordinates, to: Coordinates, unit?: DistanceUnit): number
calculateBatch(from: Coordinates, targets: Coordinates[], unit?: DistanceUnit): number[]
isValidCoordinates(coords: Coordinates): boolean

Related Data Entities (1)

Data entities managed by this component