# How to track progress on a route?

I want to track and visualize the progress of a bus, as follows:

• I have the coordinates of each station
• as well as the coordinates of the bus, updated every 10 seconds

The information is stored in Postgres, as `float` tuples, without any awareness of street topology, or other GIS-related metadata. At the moment I have a naive implementation that calculates the "as the crow flies" distance between 2 points (the bus and the next expected station). This allows me to build a rough progress-bar, but due to the way the streets are laid out in certain parts of the city, sometimes these estimations are... very wrong.

My understanding is that the proper way to deal with this is to rely on "map-matching", which will do a "snap to road" transformation of the coordinates of the bus. This, in turn, will allow me to see what distance was covered, as if the entire route is a straight line:

However, I do not have the GIS experience that would give me the confidence that (1) I am on the right track and that (2) I chose the path of minimum resistance.

What are the best practices in addressing this problem?

Update: the current software is a pure Python program that performs these calculations. No GIS tools are involved at all, though I suspect that the problem at hand is probably a typical scenario for them. I would prefer a solution that uses free/libre open source software, which can be integrated into existing systems, a Python API would be a plus.

• which software? Commented Apr 26, 2019 at 23:49
• I've appended this info to the question. At the moment it is a custom-written Python program that loads coordinates from a Postgres database and does all the calculations by itself. I am willing to try whatever tool makes the job easy, though free/libre software is a preference. Commented Apr 27, 2019 at 7:46

• 1. as I understand, Shapely is for calculations on a Cartesian plane - is it "good enough" for small-scale practical purposes on a geoid? 2. Is `LineString` the appropriate structure for storing the information about stops on a route? Commented Apr 29, 2019 at 8:05