I realised I may have been overthinking the complexity of distance calculation in my upcoming running app. I was concerned about receiving location updates with different accuracies when the runner was standing still, so was clustering them and using a centroid value so as not to add a distance when it did not need to be done.
This highlighted a side effect whereby looped courses would cause the distance to be under read.
I’ve gone back to a simplistic calculation now and factored velocity in.
Time to test it with a run!
Perhaps I should have checked that the GUI was still updating before I went out.