As for me in relation to the algorithm you described, it is that it is “greedy” and can select the “wrong” segment of the track (or at least the segment of the track that is not the closest to the point).
Time to push ASCII art to limitations. Consider the following path (numbers represent the sequence in the list of track points) and the X coordinate (and, later, Y).
1-------------2 | | Y X | 5-----+-----6 | | | | 4-----3
How should we interpret your description?
[C] display the distance from the first point of the track to the new coordinates and the distance for the interval for the first two reference points. If the distance to the measured coordinates is less than the distance from the first to the second point of the track, [assume] that this point is between this interval; [...] [i] f more, [...] check with the following interval.
I think the first sentence means:
- Calculate the distance from TP1 (point of track 1) to TP2 - call it D12.
- Calculate the distance from TP1 to X (name it D1X) and from TP2 to X (name it D2X).
The hard part is the interpretation of a conditional sentence.
My impression is that if D1X or D2X is smaller than D12, then it is assumed that X will include (or closest) the segment of track TP1 to TP2 (let's call it segment S12).
Looking at the position of X in the diagram, it will be clear enough that both D1X and D2X are smaller than D12, so my interpretation of your algorithm will interpret X as related to S12, but X is clearly closer to S23 or S56 than S12 (but they are discarded, without even reckoning).
Am I misunderstood something about your algorithm?
Thinking about it a bit: I realized that your algorithm means that if the point X lies either in a circle of radius D12 centered on TP1 or in a circle of radius D12 centered on TP2, then you associate X with S12. However, if we also look at point Y, the algorithm that I suggest you use will also associate it with S12.
If the algorithm is refined to say MAX(D1Y, D2Y) < D12 , then it does not consider Y related to S12. However, X is probably still considered to be associated with S12, and not with S23 or S56.