The ticket that came in to the customer support line read exactly like this: "Our vehicle was parked on Saturday with the ignition off, and I had the keys. Your system shows it drove 4.2 kilometers. Don't slander my driver." We opened the map; while the vehicle really was sitting under the roof of an indoor parking garage, its position had bounced around in a cloud of points, and the system had added up those jumps into an imaginary 4.2-kilometer distance. The driver was right. The GPS had lied, and we had put that lie on the invoice.
In the spring of 2019, this was the most embarrassing class of bug on our fleet platform: stationary vehicles "walking." But once we got to the root of it, the problem turned out to be less a single bug than our misunderstanding of the nature of GPS.
Not a Point, but a Cloud of Probability
When a GPS receiver gives you a coordinate, what it's really saying is: "The true position is somewhere inside an ellipse of uncertainty around this point." Under open sky, that ellipse has a radius of 3-5 meters; but in an indoor parking garage, between tall buildings, on a tree-lined road, or with an antenna mounted at the bottom of a truck body, it can swell to 30-50 meters. When the signal bounces off a building and reaches the receiver by an indirect path (multipath), the receiver measures the distance as too long, and the point suddenly jumps to the other side of the street.
The receiver actually confesses this uncertainty: inside the NMEA sentences there's a field called HDOP, a coefficient for the effect of satellite geometry on horizontal accuracy. An HDOP below 1 means the geometry is very good; above 5, it means don't trust that coordinate. Our first-generation code parsed the HDOP field and wrote it to the database but never used it in any decision. For years we had a "this measurement is garbage" label in our hands, and we never read it.
The First Wrong Answer: Thresholds on Top of Thresholds
Our first reflex was to pile up rules. If HDOP > 4, drop the point. If the speed between two points exceeds 160 km/h, drop it. Ignore points that arrive while the ignition is off entirely. In three weeks we wrote a "point customs checkpoint" made of if-else statements, and in the short term the complaints went down.
Then the side effects started. Because we were ignoring ignition-off points, we missed the theft route of a vehicle being moved by a tow truck (that is, a vehicle that really was changing position with the ignition off), which is unforgivable from the customer's point of view. The speed threshold was also eliminating the first valid point of vehicles coming out of tunnels, because with no points arriving inside the tunnel, the distance between two measurements grows and the calculated "speed" shoots up to non-physical values. Every new rule contradicted two old ones. The fundamental flaw of the threshold approach is this: it makes an independent decision for each point, while there's a huge body of accumulated knowledge from the past about where the vehicle could be.
Teaching the Filter Physics
Before turning to the literature, we tried one more interim solution: a moving average. Averaging the last five points smoothed out the jumps, but on curves it cut corners and routed the track through buildings, and on sudden stops it "slid" the vehicle to a halt 40-50 meters further ahead. An average gives equal weight to the past, while what we needed was weighting that changes with confidence. The moment we put that sentence together, we had actually started reinventing the Kalman filter without realizing it.
The Kalman filter uses exactly this accumulated knowledge. The idea isn't as scary as it looks from the outside: you have an estimate of the vehicle's state (position + velocity), and every time a new measurement arrives, you weigh two things. How much do I trust my estimate, and how much do I trust the measurement? The new state is the confidence-weighted average of those two pieces of information. If the measurement is noisy (high HDOP, few satellites), the filter listens to the measurement less; if the estimate hasn't been updated for a long time (coming out of a tunnel), it pays more attention to the measurement. The coefficient they call the famous Kalman gain is the mathematical form of this bargaining.

We built a constant velocity model: the state vector is latitude, longitude and two velocity components. Instead of taking the measurement noise matrix as a constant, we derived it from HDOP: at HDOP 1 we assumed a measurement standard deviation of 5 meters, at HDOP 4, 20 meters. That way, the field we had been throwing away for years became the filter's most valuable input. We tuned the process noise (the vehicle's maneuverability) separately for urban and intercity profiles; with a single profile we were either cutting corners or letting parked-vehicle jitter through.
For the parking problem we added one more layer on top of the filter; in the literature it's called ZUPT (zero velocity update). If the ignition is off and all of the last 10 measurements fall within a 25-meter circle, we declare the vehicle "anchored": we pin its position to the centroid of that cluster and freeze the distance counter. A single jump isn't enough to leave anchor; three consecutive measurements have to progress in a consistent direction. That way, parking garage jitter doesn't generate distance, and a vehicle being moved by a tow truck is caught three points later.

What the Numbers Said
We ran the change in shadow mode first: for two weeks, the old and new pipelines processed the same raw data, and we only recorded the new one's output. For comparison, we equipped a 12-vehicle test fleet with tachographs and manual odometer readings. The old system's daily distance error averaged 5.8 percent (11 percent on the worst vehicle, whose antenna had been mounted under the glove box). In the new pipeline, the average error dropped to 1.3 percent. False movement alarms for stationary vehicles fell from 340 a month to 9; seven of the remaining 9 were vehicles that really were being moved by tow trucks, meaning the alarm was correct. The rate at which route lines on the map passed through buildings dropped visibly. We didn't measure that, but the sales team said it was noticeable during demos, and I believe them.

People also wonder about the filter's cost: with a four-element state vector, the matrix operations run in two-by-two blocks, and a measurement update per vehicle is on the order of microseconds. We measured the filter layer's total CPU share on the stream of 3,000 vehicles; it wasn't even 2 percent of a single core. So the "Kalman is expensive" myth, at least at this scale, is a big nothing. What's expensive isn't the filter itself, but the oddities you can't trace for weeks after tuning its parameters wrong.
We had one surprise too: the filter showed some short real movements with a 2-3 second delay, because its confidence in the estimate was fresh. On the live tracking screen this delay isn't noticeable, but in geofence (zone violation) alarms it could shift the trigger moment for vehicles moving along the boundary. We updated the alarm engine to work with filtered rather than raw data, but with hysteresis: we required being 30 meters inside the zone to count as entering and 30 meters outside to count as exiting. That also put an end to alarms ping-ponging along the boundary.
And to be honest: the filter isn't a cure-all. On a vehicle whose antenna was buried inside a metal cab, the raw data was so bad that the filter output stayed unreliable too; math can only compensate for physics up to a point. For that customer, the solution wasn't software but a 15-minute change to the antenna mounting. Looking at the hardware before trying, out of a developer's reflex, to solve every problem in code: we learned that one the expensive way, too.
If only one sentence from this post sticks, let it be this one: a GPS point isn't a fact, it's a claim; any system that collects claims without questioning them will sooner or later slander its own customer. If you're seeing similar phantom movements or inflated mileage in your location data, send us a message; discussing which filter parameter breaks what is the most enjoyable part of this job.