Skip to Content
Front pageLabsLabs, projects & CCNA notes

GPS tracking

How Comma's browser tracker and native Android tracker record distance, and how their filters compare with MileWage's track engine.


Comma has two GPS trackers. The web app uses the browser's Geolocation API. The phone app uses a native Kotlin foreground service.

Web tracker

GPSTracker in web/src/core/gps-tracker.js runs navigator.geolocation.watchPosition in high-accuracy mode while a shift is active.

FilterThreshold
AccuracyFixes worse than 25 m are discarded.
Stationary jitterMovements under 10 m are discarded.
SpeedJumps above 150 km/h are discarded.
Route lengthA route is capped at 2,000 points.

The tracker stores its running totals in localStorage, so a page reload does not reset the distance.

KeyContents
comma_active_gps_distanceTotal distance in kilometres
comma_active_gps_dead_distanceDead distance in kilometres
comma_active_gps_active_distanceActive distance in kilometres
comma_active_gps_first_orderWhether Got First Order was tapped
comma_active_gps_last_coordThe last coordinate, for the next Haversine step

Limitation: the tracker runs only while the tab is open and in the foreground. A browser cannot record GPS in the background, so a locked phone stops the recording. This limitation led to the native phone app.

Phone tracker

The comma-tracker module is a Kotlin foreground service.

BehaviourDetail
SamplingA fix about every 10 seconds or every 20 m
Speed guardFixes that imply more than about 150 km/h are discarded.
Movement checkSpeeds under 5 km/h are classified as not driving.
Route simplificationRamer-Douglas-Peucker at about 10 m
Location sourceGoogle's fused location provider with Activity Recognition

Active and dead distance

Comma splits distance in two ways at once:

  • By the Got First Order tap. Distance before the tap is dead, and distance after it is active.
  • By speed. Movement below 5 km/h is not counted as driving.

The split depends on the driver tapping the button during the shift.

Comparison with MileWage

MileWage replaced both trackers with one engine. The differences follow from six months of using Comma on real shifts.

Comma (phone)MileWage
Location sourceFused provider, Google Play ServicesPlatform LocationManager, GNSS only
Cadence10 s or 20 m5 s, no distance filter
Accuracy filter25 m on the web tracker50 m on the phone and the server
Minimum move20 m distance filter20 to 50 m, scaled with reported accuracy
Stored pointsSimplified routeEvery raw fix
Active and dead splitManual tapEstimated from stops, correctable on the web
Where the total is computedOn the deviceOn the phone and again on the server
ArithmeticFloating pointInteger decimetres
Shift indicatorFloating overlay (SYSTEM_ALERT_WINDOW)Standard notification

The MileWage rules are documented in Mileage engine.

Back to top