Hi Grant, On Tue, Oct 22, 2013 at 03:13:50PM +0100, Grant Slater wrote: > I have a near live feed of bus positions for around 130 buses and > (soon) all the passenger bus routes. Routes are relations in OSM. > > Does anyone have experience or firm suggestions on how best to match a > live feed of bus positions to a set route? > > Feed Data: > * BusID (no direct match to route) > * Timestamp > * Position > * Travel Direction (Degrees) > > I also have 2 weeks worth of historical data. > > Typically: > * Bus A will drive from depot to start of route 1 and loop on route 1 > all day... maybe route 4 tomorrow. > * Bus B as above but does route 2 and then route 3... > * Bus C will be deployed on any route as required. > > All routes may share a few short segments.
I'd try something like this: Take route relations from OSM and split up into lots of segments with each segment having a list of routes it belongs to. Then for each bus every time you get a position, find nearest segment. Get list of routes from this segment and note as possible routes for this bus. Repeat until the list of possible routes for a bus only contains one route. You might have to do not only nearest segment, but a few nearest depending on how good the position data is. All of this should be easy to do with a bit of PostGIS magic. To allow for route changes as you describe, you can keep a list of the last n matches to routes and calculate some kind of probability for each route instead of the simple approach described above. This will probably needs some fiddling around depending on how your routes look and how the data from the buses look like. Jochen -- Jochen Topf [email protected] http://www.jochentopf.com/ +49-721-388298 _______________________________________________ dev mailing list [email protected] https://lists.openstreetmap.org/listinfo/dev

