sensor/gtfs: add sanity check, origin earlier than destination (#2265)

Previously experienced issues on routes where services operate in both
directions. The query picked up not just paths where service goes
from Origin ->  Destination, but trips going Destination -> Origin,
and shown bogus results.

Ensure that this doesn't happen by requiring the origin station's
stop_sequence value to be lower than the destination station.
This commit is contained in:
Gergely Imreh 2016-06-10 11:48:12 +08:00 committed by Robbie Trencheny
parent 38639d26ea
commit abc353c083

View File

@ -68,6 +68,7 @@ def get_next_departure(sched, start_station_id, end_station_id):
AND time(origin_stop_time.departure_time) > time(:now_str)
AND start_station.stop_id = :origin_station_id
AND end_station.stop_id = :end_station_id
AND origin_stop_time.stop_sequence < destination_stop_time.stop_sequence
ORDER BY origin_stop_time.departure_time LIMIT 1;
""".format(day_name=day_name))
result = sched.engine.execute(sql_query, now_str=now_str,