V2 Predictions by Stop Headsign Issue

38 views
Skip to first unread message

Samuel Custer

unread,
Dec 6, 2016, 9:25:01 AM12/6/16
to MBTA Developers
If I look at the predictions for some stops their trips' headsigns are the name of the same stop. How could a train arriving at North Station be headed to North Station?

Developer at MBTA

unread,
Dec 6, 2016, 1:04:02 PM12/6/16
to MBTA Developers
Hello Samuel,

I think perhaps what you are getting at is, why do we include arrival predictions for the last stop of a trip, and how can a developer filter these out?

As you mention, queries such as this one for Commuter Rail predictions at North Station include both departure predictions for trains that will be leaving soon from North Station, as well as arrival predictions for trains that are approaching North Station. We also include last-stop arrival predictions in the predictionsByRoute queries such as this. We include this information because it may be relevant to some app users, such as those who are currently on the train and want to know when they will arrive at North Station.

Unfortunately, there currently is not a good way to filter out predictions that are for the last stop of a trip using only API calls. We do plan on introducing such a feature in a future API update, but we cannot commit to any timeline right now for that. In the meantime, this can be accomplished using the GTFS file - we recommend using the pickup_type field in the stop_times.txt file. A pickup_type of 0 indicates a regular stop where passengers may board the train, while a pickup_type of 1 means that this is not a stop where passengers board the train (typically meaning it is the last stop of the trip). If your application uses GTFS, this method can be used to find trip/stop combinations that should be filtered out of the API call results if you are only concerned with passengers waiting on the platform, rather than those on-board the train.

I hope this helps with your development efforts.

Sincerely,

Developer@MBTA

StefanW

unread,
Dec 6, 2016, 1:36:39 PM12/6/16
to MBTA Developers
Maybe I'm missing something, but it's always seemed to me that handling the last stop of a trip is simply a matter of testing if 
( trip_headsign == stop->stop_name )

If they are the same, then that's a specific case.

I do exactly this for customizing the status text as in "now arriving at destination Wachusett". The word "destination" only gets added if the headsign equals the stop name.


Samuel Custer

unread,
Dec 7, 2016, 10:13:39 AM12/7/16
to MBTA Developers
Yeah, I can filter it out myself using lodash, I was just wondering why they were popping up. But yeah that makes sense. Thanks for the quick feedback!

Developer at MBTA

unread,
Dec 7, 2016, 1:14:21 PM12/7/16
to MBTA Developers
All:

Please note, Stefan's solution does work right now, but we can't guarantee that headsign values will always be exactly equal to stop_name values. For example, we might decide to use a trip_headsign like "Wachusett (Express)" to provide more information about a particular trip. Of course, if we did make such a change, we would notify developers well in advance via this forum.

Sincerely,

Developer@MBTA
Reply all
Reply to author
Forward
0 new messages