{"action":"created","issue":{"url":"https://api.github.com/repos/OneBusAway/onebusaway-application-modules/issues/142","labels_url":"https://api.github.com/repos/OneBusAway/onebusaway-application-modules/issues/142/labels{/name}","comments_url":"https://api.github.com/repos/OneBusAway/onebusaway-application-modules/issues/142/comments","events_url":"https://api.github.com/repos/OneBusAway/onebusaway-application-modules/issues/142/events","html_url":"https://github.com/OneBusAway/onebusaway-application-modules/pull/142","id":103117645,"number":142,"title":"Fix per-stop predictions (#127, #138, and #139)","user":{"login":"barbeau","id":928045,"avatar_url":"https://avatars.githubusercontent.com/u/928045?v=3","gravatar_id":"","url":"https://api.github.com/users/barbeau","html_url":"https://github.com/barbeau","followers_url":"https://api.github.com/users/barbeau/followers","following_url":"https://api.github.com/users/barbeau/following{/other_user}","gists_url":"https://api.github.com/users/barbeau/gists{/gist_id}","starred_url":"https://api.github.com/users/barbeau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/barbeau/subscriptions","organizations_url":"https://api.github.com/users/barbeau/orgs","repos_url":"https://api.github.com/users/barbeau/repos","events_url":"https://api.github.com/users/barbeau/events{/privacy}","received_events_url":"https://api.github.com/users/barbeau/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-25T21:05:53Z","updated_at":"2015-09-01T21:14:24Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/OneBusAway/onebusaway-application-modules/pulls/142","html_url":"https://github.com/OneBusAway/onebusaway-application-modules/pull/142","diff_url":"https://github.com/OneBusAway/onebusaway-application-modules/pull/142.diff","patch_url":"https://github.com/OneBusAway/onebusaway-application-modules/pull/142.patch"},"body":"This PR includes several commits that provide targeted fixes for issues #127, #138, and #139, in order to properly support multiple `stop_time_updates` for a single trip from a GTFS-rt source.  This is follow-on work to https://github.com/OneBusAway/onebusaway-application-modules/commit/ad8870b6961add5fa004b9c5ceb7df9a26c51fff, which enabled the consumption of multiple `stop_time_updates` for a single trip from a GTFS-rt source.  This PR focuses on the proper generation of predicted arrival and departure times for each stop, based on the GTFS-rt input.  Some of the source code to support per-stop predictions internally in OBA was already in place even prior to the above patch (including the code to figure out which stop deviation should be applied to a given stop), and this PR brings everything together in working order.  It also adds a significant amount of documentation via comments and Javadocs to better explain what's happening in plain English.\r\n\r\nWe also include a number of tests for `ArrivalAndDepartureServiceImpl` in `ArrivalAndDepartureServiceImplTest` (via 1a74a49f42cfde389179f90a97c70cdcc4cdcbda) to ensure that the predicted arrival and departure times provided by `ArrivalAndDepartureServiceImpl` are correct, given a set of input time point predictions for one or more stops.  This includes verifying that the behavior of OBA is consistent with the GTFS-rt spec, especially for the propagation of arrival/departure times downstream in a trip.  We include multiple commits in this PR because they are interrelated, and all are needed for the tests to pass.\r\n\r\nIt should be noted that this implementation of per-stop predictions is used to produce arrival/departure times even if a GTFS-rt source only provides a single prediction for a trip - in other words, single predictions per trip are just a special case of multiple stop predictions per trip where n is the number of per stop predictions, and n = 1.\r\n\r\nOne additional item of note - as mentioned above, we built on existing OBA code to support multiple predictions per trip, which was our least invasive option.  This code therefore keeps the original OBA internal data model of supporting one deviation per stop.  As a result, there are two situations (marked by `TODO` statements in `ArrivalAndDepartureServiceImplTest`) where OBA can't entirely represent both arrival and departure information correctly for the same stop.  We include two commented-out unit tests for these situations, which can be uncommented if future works overhauls the OBA internal model to fully support arrival and departure deviations for each stop.  Specifically, these situations that aren't supported are:\r\n\r\n1. A departure prediction is provided for Stop A, but no arrival prediction is provided for Stop A, and the predicted arrival for Stop A is requested\r\n2. Both arrival and departure predictions (which have different deviations) are provided for Stop A, and the predicted arrival for Stop A is requested\r\n\r\nIn both cases, the departure prediction deviation (which is predicted_departure - scheduled_departure) would be returned as the arrival prediction deviation.  This is because if we can only support one deviation per stop, we should prefer departure deviation so it's propagated downstream.  I don't believe the current OBA UIs and apps would even expose this limitation, as they show departure info when its provided (but someone correct me if I'm wrong).  So, for us, the risks and amount of work required to overhaul the entire internal OBA data model far surpassed the need to try and fix these two corner cases.  We do include the (commented out) unit tests to verify correct behavior for these two cases, though, if this problem is tackled in the future.\r\n\r\nFinally, I want to say a huge thanks to @cagryInside, who spent a lot of time debugging OBA so we could better understand what was happening inside OBA.  This PR definitely wouldn't have been possible without him!\r\n\r\nWe'd love to get feedback on this, especially from @bdferris @kurtraschke and @sheldonabrown.  We've been testing this with real data in Tampa, and we'll continue to test more heavily in the upcoming weeks.  If anyone else has access to real GTFS-rt feeds (or another data source format) that provides multiple stop predictions per trip, it would be great if you could test this out as well, or at least provide us with the feeds so we can take a look."},"comment":{"url":"https://api.github.com/repos/OneBusAway/onebusaway-application-modules/issues/comments/136863140","html_url":"https://github.com/OneBusAway/onebusaway-application-modules/pull/142#issuecomment-136863140","issue_url":"https://api.github.com/repos/OneBusAway/onebusaway-application-modules/issues/142","id":136863140,"user":{"login":"barbeau","id":928045,"avatar_url":"https://avatars.githubusercontent.com/u/928045?v=3","gravatar_id":"","url":"https://api.github.com/users/barbeau","html_url":"https://github.com/barbeau","followers_url":"https://api.github.com/users/barbeau/followers","following_url":"https://api.github.com/users/barbeau/following{/other_user}","gists_url":"https://api.github.com/users/barbeau/gists{/gist_id}","starred_url":"https://api.github.com/users/barbeau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/barbeau/subscriptions","organizations_url":"https://api.github.com/users/barbeau/orgs","repos_url":"https://api.github.com/users/barbeau/repos","events_url":"https://api.github.com/users/barbeau/events{/privacy}","received_events_url":"https://api.github.com/users/barbeau/received_events","type":"User","site_admin":false},"created_at":"2015-09-01T21:14:24Z","updated_at":"2015-09-01T21:14:24Z","body":"@sheldonabrown Also, HART data is in that server instance, and seems to match up against tampa.onebusaway.org nicely (HART is providing only single predictions per trip)."}}