-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RPC to get hours of service for a station/route #14
Comments
I really like this idea, but I'm not entirely sure it can be implemented in this way without losing some information in the process. Obviously, this is a solved problem, as other services are able to provide this information, though, their implementation may not be automatic in the way that we would like it to be. I'll try to build up my understanding of why I don't think this will work exactly as we want (or at least won't be trivial). (Simplified) Implementation OverviewFirst, let's assume that a route only has one trip. GTFS directly contains the information for part of the "range of weekday-times" field through the mapping of The time range portion is fairly simple. Just iterating all The last portion is potentially the most difficult. It could potentially suffice to iterate all of the With that, I would propose to modify the response of this RPC to something along the lines of the following: timetable.service_times(station, route) -> (days-with-service, time-range, visit-interval)
# Example:
timetable.service_times('BUS123', '1B') -> ([Mon,Tue,Thu,Sat], [06:45:00, 18:00:00], 00:00:05) Multiple Trips per RouteIt is almost always the case that a Route will consist of multiple trips, each potentially with their own service (and thus date-range) and time-range. The easiest way I can think to support this is to simply create a response for each trip and join them all in an array. The format would then be adjust to the following: timetable.service_times(station, route) -> [(days-with-service, time-range, visit-interval)]
# Example:
timetable.service_times('BUS123', '1B') -> [([Mon], [06:45:00, 18:00:00], 00:00:05), ([Thu,Fri], [07:45:00, 20:00:00], 00:00:10)] Attempting to collate this information into a single response (to me) would either lose information (as the intervals may be different between trips, but collating would require dropping all but one interval as the representative. Or, the time range may be different, etc.). Collating by ServiceIn my experience with CityBus's data, trips are (mostly) organized into services such that all of the vehicles that are traveling a route on a given day belong to the same service. Additionally, the time interval between vehicles on different trips for the same service seems to stay consistent. With that, it may be possible to collate trips that are on the same service to the same entry in the response above (where the response is an array). With these assumptions, it would be possible to collate the interval by merging the two sets of stop_times and calculating the difference between two of them. It would also be possible to merge the time-range by doing a min/max on all of the range beginnings and endings to get a complete timebox. As all of the trips are on the same service, the date-range would not need any merging, as that information comes from the service itself. My only concern with this is that I don't know if we can make those assumptions. If we do, what happens when our assumptions aren't met? Do we simply say that the information is unavailable? Make a best attempt? I'm not sure. Additionally, services are not necessarily active for the entire date range that a GTFS archive covers. The ConclusionI don't know what the best format for the response is, but I'm inclined to follow Google Maps' implementation of Store Hours for this, where the days are separated and the hours are shown for each day, and only the services for a given week are shown. The issue of collating information for each day across services/trips is still present with this solution, but I believe it will be easier than attempting to do a general collation for the feed's entire duration, and will avoid having to indicate exceptions that may be defined within that range. I don't know what the implementation of this format would look like to Timetable (or to callers, for that matter). I'll be thinking about it tonight and tomorrow and will hopefully have a better idea then. tl;dr: |
I think this is fine—building some sort of disjoint range (if needed) should be an exercise for the client. I'm not sure I can speak much into the feasability of coaxing this information out GTFS. One thing I was thinking though, was that I could write a call like this on top of The purpose of visit intervalsOne thing to consider is the UI goal. A user story for this feature would read something like: As a transit rider, I need to know the schedule of the bus I take throughout the week. This way I can plan ahead and know when I can expect to catch it. Knowing when it isn't running, like on weekends or at night, is necessary, but also knowing how frequently it stops is important: it allows me to determine how long I'd have to wait (should I catch this bus or just wait for the next one?), and to know if service slows down at certain times, like in the early mornings and late evenings. With this in mind, I think it's important to be able to report inconsistencies in the visit interval. For CityBus, some routes (1B and 5A, at least), run at 2x service during daytime hours and go from arriving every 30 min to every 15 min. Normalization algorithmtl;dr Take an average of stop times, but break into multiple visit intervals after passing a certain differential. What if we chose a small time window (
This would allow discrepancies in the stop time, but significant changes would report as a separate interval. The RPC would return time ranges associated with time intervals, like this:
For routes with irregular schedules, this algorithm would produce a bunch of insignificant
|
I like this solution. I think it provides the most accurate view of the frequency information while avoiding being overly verbose. In fact, I had forgotten about one of the optional GTFS files, However, even with this solution, there is still an issue with how to collate multiple trips together. Remember that different trips for the same route can belong to different services, and those services can be activated on arbitrary dates, so I feel like there still needs to be a time bound for the period in which the response is valid. If we just want it to be the day that the request is made, that should be fine, but I feel like that makes the information somewhat less useful. I'd like to somehow merge your solution with the Store Hours solution I mentioned before. Maybe we can bound the response to a week (always Sunday-Saturday, no matter the current date), and then have the response be a 7-element list following the format you specified for each day. I think it may be worth discussing over a voice call or similar to better pass ideas back and forth on this. I think there is a little too much detail to really be able to write out ideas. |
FWIW, if we implement that combination of solutions, I believe clients would be able to say things like |
Closing in favor of propershark/proto#1. |
It'd be useful to have an RPC to determine when a particular route makes stops at a station. This would allow clients to say something like:
"Route 13 stops here Mon-Fri, 7:00am-6:00pm, every 5 min"
So, the call would look something like
and would return
Mon 07:00...Mon 18:00
orTue 19:00...Wed 02:00
) for a particular level of serviceThe text was updated successfully, but these errors were encountered: