<div dir="ltr">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.)<div>
<br></div><div>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.<div>
<div><br></div><div>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 <a href="https://github.com/ericfischer/check-one-way">https://github.com/ericfischer/check-one-way</a> 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.</div>
<div><br></div><div>Eric</div><div><br></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Oct 22, 2013 at 7:13 AM, Grant Slater <span dir="ltr"><<a href="mailto:openstreetmap@firefishy.com" target="_blank">openstreetmap@firefishy.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi OSM-Dev,<br>
<br>
Dev challenge...<br>
<br>
I have a near live feed of bus positions for around 130 buses and<br>
(soon) all the passenger bus routes. Routes are relations in OSM.<br>
<br>
Does anyone have experience or firm suggestions on how best to match a<br>
live feed of bus positions to a set route?<br>
<br>
Feed Data:<br>
* BusID (no direct match to route)<br>
* Timestamp<br>
* Position<br>
* Travel Direction (Degrees)<br>
<br>
I also have 2 weeks worth of historical data.<br>
<br>
Typically:<br>
* Bus A will drive from depot to start of route 1 and loop on route 1<br>
all day... maybe route 4 tomorrow.<br>
* Bus B as above but does route 2 and then route 3...<br>
* Bus C will be deployed on any route as required.<br>
<br>
All routes may share a few short segments.<br>
<br>
Kind regards<br>
Grant<br>
<br>
_______________________________________________<br>
dev mailing list<br>
<a href="mailto:dev@openstreetmap.org">dev@openstreetmap.org</a><br>
<a href="https://lists.openstreetmap.org/listinfo/dev" target="_blank">https://lists.openstreetmap.org/listinfo/dev</a><br>
</blockquote></div><br></div>