GPX Lap Timer

Define a start/finish line in your GPX and auto-detect lap times

Paste a timestamped GPX track and a start/finish gate (two coordinates), and the tool detects every crossing of that line and computes each lap's duration. Built for motorsport, cycling, and running data. Runs entirely client-side. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

How is a line crossing detected?

For each consecutive pair of track points, the tool checks whether that segment intersects the gate line using a standard 2D segment-intersection test on longitude and latitude. The exact crossing time is interpolated between the two points based on where along the segment the intersection falls.

GPX Lap Timer turns a recorded GPS track into lap times. Define a virtual start/finish line as two coordinates, and the tool finds every point where your track crosses that line, then measures the time between consecutive crossings. It works for any looping activity — track days, criteriums, running laps — and runs entirely in your browser.

How it works

The track is read into an ordered list of points, each with a longitude, latitude, and timestamp. The gate is a line segment defined by two coordinates. For every consecutive pair of track points, the tool tests whether the segment between them intersects the gate using the orientation-based segment intersection test: two segments cross when their endpoints straddle each other, detected via the sign of cross products.

When a crossing is found, the exact moment is interpolated. The intersection’s position along the track segment gives a fraction t, and the crossing time is time₁ + t × (time₂ − time₁). The duration of each lap is the difference between consecutive crossing times. A cooldown after each crossing suppresses duplicate triggers from points sitting right on the line.

Tips and example

Place the gate perpendicular to your direction of travel and wide enough to span the racing line, but short enough that the track only crosses it once per lap. If your fastest lap is, say, 90 seconds, a 10-second cooldown comfortably prevents double counts without missing real laps. Paste the sample, keep the suggested gate, and you will see the crossings and per-lap durations listed in order.

Getting good results from your GPS data

Timestamp requirements

A lap timer is fundamentally a clock, so every track point must include a time element. GPX files exported from consumer GPS devices (Garmin, Wahoo, Apple Watch, most cycling computers) include timestamps by default. GPX files downloaded from Strava or Komoot as route files — rather than activity recordings — may omit timestamps because they describe a planned path, not a recorded one. Always export from the activity record, not the route.

Placing the gate effectively

A gate that is too long may be crossed by the infield or pit lane as well as the racing surface, generating phantom lap records. A gate that is too short may be missed entirely if GPS accuracy drifts by a few metres on a given lap. Good gate placement guidelines:

  • Set the gate perpendicular to your direction of travel at the start/finish line.
  • Make it slightly wider than the widest racing line you ever use at that point.
  • Place it where the track only crosses in one direction per lap to avoid needing to handle bidirectional crossings.
  • If the circuit has a large run-off area, avoid placing the gate across a line the car could reach during an incident lap that would register as an early crossing.

Understanding the cooldown

The cooldown is a minimum time (in seconds) that must elapse after a crossing before the next crossing is registered. Without it, a GPS recording with two points either side of the gate line — one slightly before and one slightly after — would register two rapid crossings and create a phantom lap of a few seconds. Set the cooldown to slightly less than your shortest possible lap time. For a kart circuit with 30-second lap times, 15 seconds is a reasonable floor; for a full GP circuit with 90-second laps, 45–60 seconds is safe.

Why interpolation matters for timing accuracy

GPS units typically record a point every second. At 50 kph you travel about 14 metres per second. If the exact line crossing happens between two GPS points, rounding to the nearest point could introduce half-second errors in each crossing time and compound across laps. The interpolation used here — finding the fraction t along the segment where the intersection falls and applying that fraction to the time interval — reduces the timing error to sub-second accuracy even with 1Hz GPS data.

What to do if laps are missed or doubled

  • Missed laps: the gate probably did not span the actual GPS path at that point. Widen the gate coordinates slightly and re-run.
  • Double laps: the cooldown is too short, or the gate crosses a line the track visits twice per lap (for example, across a straight where an out-and-back section doubles back). Increase the cooldown or move the gate to a uniquely single-crossing location.