How It Works
Bus Speed Test relies on the Geolocation API built into every modern web browser. Here's the short version of what happens when you press Start.
1. Asking permission
The browser displays a permission prompt asking whether the site can access your location. Bus Speed Test cannot read GPS until you say yes. The permission persists per site, so subsequent visits skip the prompt.
2. Watching position
Once permitted, we call navigator.geolocation.watchPosition with high-accuracy mode enabled. The browser then pushes a fresh GeolocationPosition to us every time the GPS chip computes a new fix — roughly once per second on most phones.
3. Reading the speed
Modern phones include a speedfield on the position object, expressed in meters per second. When available, we use it directly — it's the most accurate value the device can produce because it's computed from the Doppler shift of satellite signals.
When the field is missing (some desktop browsers, older devices), we fall back to dividing the great-circle distance between consecutive points by the time between them.
4. Smoothing & filtering
Raw GPS readings can flicker by a few km/h even when you're standing still. With smoothing on (the default), we keep a rolling 5-sample average so the dial reads steadier. If your accuracy drops below ~100 m, we also pull back any suspiciously high readings.
5. Converting units
The raw value stays in m/s internally; we convert on the fly when rendering. Conversion factors are exact: km/h = m/s × 3.6, mph = m/s × 2.23694, knots = m/s × 1.94384.
6. Distance & average
Every new fix adds a small leg to the trip — calculated with the haversine formula, which accounts for the curvature of the Earth. Movement smaller than the GPS accuracy is discarded so drift while waiting at a stop doesn't inflate your total distance.
The average speed is just the running mean of every sample since you pressed Start. Stops are included, so a 50 km/h cruise with a 5 minute red light will show a lower average than the cruise itself.
What about accuracy?
Consumer-grade GPS in a typical smartphone is accurate to roughly 3–10 meters when the sky is clear. Speed readings are usually even better than that, because Doppler-based speed estimation doesn't depend on position accuracy.
Accuracy suffers under bridges, in tunnels, in dense urban canyons, and indoors. The accuracy figure in the bottom of the dial shows how confident the browser is about your current fix — lower numbers are better.
Ready to try it? Head back to the speedometer.