maps · gps · ecowell · reliability

Measuring How Far a Technician Really Traveled

2 December 2026 · 2 min read

Technicians are paid and reimbursed partly on distance, so the kilometre figure has to be defensible. GPS from a phone is noisy, phones go offline, and people are tempted to game anything that touches money. This post covers the design.

A fox technician walks a dotted GPS trail while a cat measures its true length

Audit first, then build

Before writing code, we audited what already existed against each requirement and labelled every row: already implemented, partial, missing, or implemented in this pass. The useful part was the “partial” rows. For example, location pings were accepted only within 2 minutes of the device timestamp, which sounds safe but rejects legitimate samples from a phone that was offline in a basement and synced later. Auditing found that gap before users did.

Cleaning the signal

Distance is the sum of straight segments between consecutive pings (the Haversine formula), after filtering:

  • Order by device capture time, not arrival time, so late uploads slot into the right place.
  • Drop invalid or out-of-range coordinates.
  • Drop mock-location samples.
  • Drop samples whose reported accuracy is worse than 100 m.
  • Drop impossible jumps (50 km or more between consecutive samples).
  • Only count samples inside the technician’s clock-in to clock-out window.

Known weakness, stated plainly: this does not yet handle stationary drift, where a parked phone wanders by a few metres and slowly adds fake kilometres.

Idempotent, never fabricated

  • Each ping carries a stable sample_id from the device. Replaying the same ping returns the same result (replayed: true) instead of double counting. Reusing the id with different data is a 409.
  • The server stores both captured_at (device time, never rewritten) and received_at (server time). We never invent samples to fill gaps.
  • Clock-out is idempotent too: repeating it returns the same closed record. It finalizes the day’s kilometres and never touches cash or custody records, keeping distance tracking separated from money.

Every kilometre belongs to something

A segment is assigned once, either to a specific job or to “other duty travel”, so a drive that overlaps two job windows cannot be counted twice. The report shows technician, job and other-travel totals per day for a range of up to 31 days.

Proof of presence

Clock-in requires a selfie, and we treat it as evidence, so it gets the strict path:

  1. The app asks for an upload intent (expires in 10 minutes, single use).
  2. Bytes go to private storage. No public URL exists.
  3. The server checks size, format and SHA-256, then re-encodes the image to a canonical JPEG.
  4. Clock-in accepts only an intent that the same technician owns and has finalized. A raw selfieUrl string is no longer treated as proof.

What is still open

The contract lists what is not done: a live roster split by department, an audited process for late reconciliation, CSV export, and an Installation-side customer tracking view. We also say clearly that this is a source and test audit, not verified on production or real devices.

Takeaways

  1. Audit against requirements before building, and label partial work honestly.
  2. Trust device time for ordering, server time for receipt, and never rewrite either.
  3. Make every command idempotent. Mobile networks retry.
  4. Keep money and measurement apart, and put evidence like selfies behind private storage with strict ownership checks.

AI use: Written with AI assistance from my own notes and project facts, then reviewed by me. Images are AI-generated. How I use AI

Loading reactions…

Working on something similar? Let's talk.

Same problem, a question about this article, a collaboration, or an open-source project you would like me to contribute to. Pick whichever door you like: