You idea to avoid re-trigger is possbile, but you should know the Lap cumulative error will occur again.
Or we can skip lap cumulative error problem?
I agree with Zingo, when he said that in this case a cumulative error wouldn't be a big problem.
So - from my point of view, it wouldn't be necessary to implement a complicated calculation.
And furthermore: I still don't see, why there should be a cumulation ?!
Of course: First Lap will be shorter than expected (~20m), but all following Laps should have
exactly the correct distance. Of course it will be necessary to keep the trigger point at the
original first starting point ! You mustn't move the trigger coordinates when a new lap is reached !
So, I'm aware that lap distances will differ caused by GPS inaccuracy, but I don't see a reason
why there should be some kind of cumulation.
For your second concern:
But I am not sure it works or will have problem of lost signal or leaving the regular track?
Yes - of course - you are right. Function will not work in case of GPS lost or when leaving
the regular track. However - I cannot see the problem:
* When GPS is lost, it is quite normal and obvious, that all (!) GPS based functions cannot work anymore.
This is not a reason for not-implementing a GPS based function...
* For leaving the track: The basic idea of the function is, to count a lap, when specific start coordinates
are reached again. If the coordinates are not reached (for whatever reason), the lap isn't counted.
That's it. No problem.