How to store one location in a given position?

Or…
Make a comparison with latitude and longitude before recording. If the difference from the current one to the previous one is very small (you will define this parameter) you will not record it. If it is a big difference (there was a big shift) then you record.