[OSM-dev] Matching live bus position to route?

Eric Fischer enf at pobox.com
Tue Oct 22 18:44:43 UTC 2013

When I've done something like this before (from NextBus data for the real
time locations and GTFS for the routes), I've done it just by chopping up
the route shapes into ~100 foot segments, putting them into 100-square-foot
buckets for quick lookup, and snapping each real-time sample to the nearest
route segment that is headed closer to the right direction. (I used the
deltas between successive samples for the same bus to determine direction
instead of the reported travel direction, since the reported one often
didn't make sense.)

The tricky part was with routes or route variations that shared the same
street, and I didn't come up with a good solution for that besides trying
to leave the bus associated with its previous route if it still came close
to matching even if another route was slightly closer.

I lost my bus route matching code in a drive failure or I would offer it,
but it's pretty much the same idea as in
https://github.com/ericfischer/check-one-way which snaps GPS points to OSM
ways and then checks the oneway=* tags to see if the ways actually go the
same direction the GPS logs suggest that they do.


On Tue, Oct 22, 2013 at 7:13 AM, Grant Slater
<openstreetmap at firefishy.com>wrote:

> Hi OSM-Dev,
> Dev challenge...
> 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.
> Kind regards
>  Grant
> _______________________________________________
> dev mailing list
> dev at openstreetmap.org
> https://lists.openstreetmap.org/listinfo/dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20131022/1401422a/attachment.html>

More information about the dev mailing list