RouteMatcher

interface RouteMatcher

The seam between "distance we computed from raw fixes" and "distance a road network says we drove".

Every gate in MileageAlgorithm — jitter, spikes, stop suppression — removes noise: symmetric error that shrinks over a long enough trip. GPS also carries a bias that noise-removal cannot touch: a straight-line (haversine) leg between two fixes on a curving road, or between two fixes either side of a switchback, is always short. Snapping the trace onto the road graph is the only correction that runs in one direction, which is exactly why it belongs on the figure that ends up on a reimbursement claim.

This is a pure interface. :location has zero dependencies and compiles for android/jvm/iOS/ wasmJs, and there is no HTTP client that runs on all four — so the network round-trip (OSRM's /match/v1/{profile}/{coords} or any equivalent) is implemented in the app or on a server, never here. What lives here is everything that does NOT need a network: preparing the request (TracePreparation) and deciding what a response means (MatchReconciliation).

match is suspend because doing the round-trip synchronously would block a thread for however long the network takes; suspend is a language feature, not the kotlinx.coroutines library, so declaring it here costs this module nothing.

Functions

Link copied to clipboard
abstract suspend fun match(request: MatchRequest): MatchedRoute