Repository navigation
Fix frequency bounds checking - #2540
Conversation
Previously, stop offsets were not taken into account, so you could not ride on a trip past it's frequency end time, even if you could have boarded it at an earlier stop (when it was still within the frequency range). This fix allows that to happen. This also fixes stop time calculation for exact trips where the (end - start) is not a multiple of headway. Previously, it calculated based on the end time, but that's a wrong assumption to make. Tests for the fixes have also been added.
|
Thanks for the contribution @thatsmydoing. Could you add a few code comments to this PR clarifying the assumptions behind the code, namely that the start and end times are the time window during which departures happen from the first stop on the trip? This does make me wonder what happens if someone searches for departures at a stop later than (freqEndTime + stopOffset - headway). While a vehicle could pass during that time window, it's unknown whether the last bus has already passed. |
|
There already is a comment saying that in nextDepartureTime. I can add one to prevArrivalTime too if that's what you'd like. This mostly targets exact frequency trips since there's no ambiguity with how the schedule is supposed to work. I have an in progress patch for dealing with inexact frequency trips, but that one has some assumptions which may or may not be okay. |
|
If there's already a comment, no need to add another one. I didn't hop between the diff and the original file so I missed it. This all sounds good, it's a good thing to have someone else revising this part of the code because we very rarely used it. Do you wan to add your other non-exact frequency updates to this same PR? |
|
Okay, I'd prefer you go ahead and merge this. The non-exact frequency patch has a bit of room for discussion so I'd like to keep that one separate. |
|
This PR has been updated to current |
|
Merging this with a single review as a simple self-containted bug fix, since it adds a test to demonstrate the fix and I have received additional complaints about this particular bug. |
Previously, stop offsets were not taken into account, so you could not ride on a trip past it's frequency end time. This causes issues when you have stops A (00:00:00), B (00:30:00), C (01:00:00). If the end_time is at 11:45, a trip from A-B of 11:30-12:00 is valid, but a trip from B-C of 12:00-12:30 should be valid but is not.
This also fixes stop time calculation for exact trips where the (end - start) is not a multiple of headway. Previously, it calculated based on the end time, but that's a wrong assumption to make.
Tests for the fixes have also been added.