Package-level declarations

Types

Link copied to clipboard

Replay a recorded trace through an algorithm and score the result.

Link copied to clipboard
value class AlgorithmId(val value: String)

Stable algorithm identity. A string so that persisted rows survive refactors of the enum-ish set.

Link copied to clipboard
data class AlgorithmState(val schemaVersion: Int = CURRENT_SCHEMA_VERSION, val cleanedM: Double = 0.0, val abnormalM: Double = 0.0, val mockM: Double = 0.0, val spikeM: Double = 0.0, val originalM: Double = 0.0, val accepted: Int = 0, val rejected: Int = 0, val consecutiveNormal: Int = 0, val maxSpeedMps: Double = 0.0, val avgSpeedMps: Double = 0.0, val lastFix: Fix? = null, val opaque: Map<String, Double> = emptyMap())

Everything needed to resume a journey across process death.

Link copied to clipboard
data class DeviceEnvelope(val accuracyCeilingM: Double = 50.0, val stationaryAccuracyCeilingM: Double = 25.0, val minDisplacementMultiplier: Double = 1.0, val abnormalThresholdMultiplier: Double = 1.0, val gpsIntervalMultiplier: Double = 1.0)

Device-derived scaling, computed once at the platform edge and handed in.

Link copied to clipboard

Which running total a fix's displacement was added to.

Link copied to clipboard
data class Fix(val lat: Double, val lng: Double, val timeMs: Long, val accuracyM: Double, val speedMps: Double? = null, val bearingDeg: Double? = null, val altitudeM: Double? = null, val isMock: Boolean = false, val provider: String? = null, val odometerM: Double? = null)

One location sample, stripped to what a distance algorithm can legitimately use.

Link copied to clipboard
data class FixResult(val verdict: FixVerdict, val emitted: Fix?, val displacementM: Double, val distanceDeltaM: Double, val bucket: DistanceBucket, val reason: String? = null)
Link copied to clipboard

What happened to a fix. Diagnostic granularity — never branch business logic on this.

Link copied to clipboard
data class KnobSpec(val name: String, val default: Double, val min: Double, val max: Double, val step: Double, val unit: String, val description: String = "")

One tunable parameter, described well enough to build a slider and run a sweep without knowing anything about the algorithm behind it.

Link copied to clipboard
data class MatchedRoute(val distanceM: Double, val confidence: Double, val pointMatched: List<Boolean>, val legDistancesM: List<Double> = emptyList())

What a map-matching provider reported for one MatchRequest.

Link copied to clipboard
data class MatchPoint(val lat: Double, val lng: Double, val radiusM: Double, val timeMs: Long)

One point as a map-matching request wants it: a coordinate, how much to trust it, and when it was recorded.

Link copied to clipboard

Decide what to present when the client's own distance and a map-matched distance disagree.

Link copied to clipboard
data class MatchRequest(val points: List<MatchPoint>)

Everything one map-matching request needs, serialization-agnostic.

Link copied to clipboard

The seam that lets more than one mileage algorithm exist at the same time.

Link copied to clipboard

Where algorithms are looked up by id.

Link copied to clipboard
class PassThroughAlgorithm(profile: TuningProfile = defaultProfile()) : MileageAlgorithm

Trust the source; filter nothing.

Link copied to clipboard
data class Reconciliation(val verdict: ReconciliationVerdict, val clientDistanceM: Double, val matchedDistanceM: Double, val presentedDistanceM: Double, val confidence: Double, val differenceRatio: Double)

The outcome of one reconciliation. Both source figures are always present — see MatchReconciliation — so a caller that disagrees with presentedDistanceM can still recover whichever figure it dropped.

Link copied to clipboard
interface RouteMatcher

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

Link copied to clipboard
data class RunReport(val algorithmId: AlgorithmId, val fixCount: Int, val finalState: AlgorithmState, val verdictCounts: Map<FixVerdict, Int>, val maxDisplacementM: Double)

What one replay produced.

Link copied to clipboard
data class Scorecard(val algorithmId: AlgorithmId, val truthM: Double, val measuredM: Double, val errorM: Double, val absErrorPercent: Double, val acceptedFixes: Int, val rejectedFixes: Int)
Link copied to clipboard
class SegmentedTripAlgorithm(profile: TuningProfile = defaultProfile(), envelope: DeviceEnvelope = DeviceEnvelope.Default, delegate: MileageAlgorithm = TieredGpsAlgorithm( TuningProfile(AlgorithmId.TieredGps, "mileway.v1"), envelope, )) : MileageAlgorithm

A decorator that adds the three corrections TieredGpsAlgorithm structurally cannot make, without touching it.

Link copied to clipboard
data class SessionContext(val startedAtMs: Long, val resumedFromPause: Boolean = false, val vehicleType: String? = null)

Journey-scoped inputs that are not properties of any single fix.

Link copied to clipboard
class TieredGpsAlgorithm(profile: TuningProfile = milewayV1Profile(), envelope: DeviceEnvelope = DeviceEnvelope.Default) : MileageAlgorithm

Kalman-smoothed, speed-adaptive GPS cleaning — the algorithm Mileway's LocationProcessor actually runs today, extracted onto the MileageAlgorithm seam so its thresholds can be swept and its output can be shadow-compared against other algorithms.

Link copied to clipboard
data class TraceCase(val name: String, val fixes: List<Fix>, val truthMeters: Double? = null, val notes: String = "")

A recorded drive plus what it is known to have actually been.

Link copied to clipboard
data class TraceChunk(val fixes: List<Fix>, val overlapWithPrevious: Int)

One request-sized window of a longer trace.

Link copied to clipboard
object TraceCodec

Read and write recorded GPS traces, so a real drive becomes a regression test.

Link copied to clipboard

Turn a raw fix stream into something a map-matching provider can actually be asked about.

Link copied to clipboard
data class TuningProfile(val algorithmId: AlgorithmId, val profileId: String, val values: Map<String, Double> = emptyMap(), val flags: Map<String, Boolean> = emptyMap())

A named set of knob values for one algorithm.

Functions

Link copied to clipboard
fun haversineMeters(lat1: Double, lng1: Double, lat2: Double, lng2: Double): Double

Great-circle (haversine) distance in metres.