Here I made one way:
On a granular level you could just count laps. A little less granular would be to count checkpoints. In the above it also incorporates the distance to the next checkpoint on top of the number of checkpoints passed.
The only major math used finds the distance to a line instead of a point.