TransWikia.com

How to track progress on a route?

Geographic Information Systems Asked by ralien on January 25, 2021

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

schematic of a bus on a route map

  • 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:

6500m out of 10000m were covered by the bus

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.

One Answer

I would try with a python library called Shapely. After you import topologies into Shapely geometry you will be able to create MultiPoint(collection of Points) geometry along the line at the specific distance. Then, the only thing you need is the closest point of this new geometry to your bus coordinates. When you have it, measure the distance from the first station to the next point of MultiPoint geometry until you reach your 'match' point with a bus. Hope it will help.

Answered by Kumbra on January 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP