I have two coordinates(latitude,longitude) which is defining line on the map. The line has direction. Then I have series of other coordinates moving either roughly along this line and towards direction or opposite direction. Also they can cross the line, etc. The important part is that I need to identify only the case when series of points are moving along and towards direction. Those series are coordinates from gps. Let's also define threshold in meters for identifying that point "belongs" to line. This will include gps error and line error.
I am looking for some formula which I could apply to each point, then after applying twice I can identify direction and continue until end of the line. Below is drawing (sorry for finger quality), hopefully demonstrating what I mean.
Green dots are series which are moving towards line direction. They are what we need to identify. Top blue dots are series moving opposite direction. Also want to emphasize that those lines are not really lines and maybe we need to consider their roundness.