Split Commuter Rail Stop IDs

67 views
Skip to first unread message

Matthew Kindzerske

unread,
Jun 29, 2023, 10:40:45 AM6/29/23
to MBTA Developers
Regarding the STOP IDs of Commuter Rail stations, some are split (there's two IDs seemingly one for each direction in/out bound).  Is there any convention to this, or a programmatic way to tell the difference besides the Schedule?

function convertInboundStationIDToOutboundStationID(inboundStopID) {
if (inboundStopID == "MM-0200-CS") { return "MM-0200-S"; } //Brockton
if (inboundStopID == "MM-0186-CS") { return "MM-0186-S"; } //Montello
if (inboundStopID == "NEC-1891-02") { return "NEC-1891-01"; } //Patucket
return inboundStopID; //else
}

Jeff @ Keolis

unread,
Jun 30, 2023, 9:39:15 AM6/30/23
to MBTA Developers
Commuter Rail stations are generally structured to include the following stop_ids:
  • A parent_station stop_id for the entire station, serving Commuter Rail and any other modes using the same station
  • A child stop_id for every Commuter Rail track existing at the station
  • An "unassigned track" stop_id at stations where there are multiple Commuter Rail tracks
  • Other station elements, like doors and navigational nodes, in addition to stop_ids for modes besides Commuter Rail

As of the May 22 Commuter Rail schedule change, Commuter Rail GTFS includes track assignments at most stations, meaning most trips are scheduled to their assigned track.

The "official" way to determine other stop_ids / tracks at the same station would be to identify the stop_ids with the same parent_station value.

I would strongly caution you to NOT use the stop_id as the basis for direction, as there are certain trains that are scheduled to board on a nonstandard track (e.g. during the PM rush hour, outbound Worcester Line trains generally board from Track 2, which is typically used by inbound trains at all other times), meaning your results would display trips using that track, not necessarily in a given direction.

If you're looking to identify trips by direction at a given station, a better approach would be to identify all trips serving any child of the parent station, filtering the results by route as applicable, and then filtering the trips based on the trip's direction_id field.

Matthew Kindzerske

unread,
Jun 30, 2023, 3:25:31 PM6/30/23
to MBTA Developers
Perfect, thank you.
Makes sense to start with parent station, in case someone else starts with Schedules first and only sees child station/IDs.
Reply all
Reply to author
Forward
0 new messages