jamespfennell / transiter

Web service for transit data
https://demo.transiter.dev
MIT License
55 stars 6 forks source link

Add `preserve_m_train_platforms_in_bushwick` option to `NyctTripsOptions` #107

Closed cedarbaum closed 1 year ago

cedarbaum commented 1 year ago

This change allows the M train platform label correction to be disabled. For my use case of Transiter, I rely on the direction suffix of platforms ("N" or "S") for determining the direction. So for the M train, north is interpreted as "towards Manhattan/Queens" and south is interpreted as "towards Brooklyn".

Looking through the history of this issue on the GTFS project, I assume that the main issue I'd now face is if I tried to use the headsign labels in the future (which would be reversed). Is my understanding correct here?

jamespfennell commented 1 year ago

Yes, from what I remember your understanding is correct. For each trip in the raw NYC subway data, the stop times are either all for stops <station_id>N or all for stops <station_id>S. There's no S and N mixing and matching within a trip. Thus by looking at the last character for any stop time for a trip, you can figure out the direction it's going in.

The option for the GTFS parser changes this behavior for the five stops between Marcy Av and Myrtle-Broadway inclusive, and flips N to S and vice-versa. So reading the direction using the last character, for the M train, will give you the wrong answer for those 5 stations.

However, if you disable this behavior you run into a different problem. This problem is that J and M trains that stop at the same platform will appear to be stopping at different platforms. Specifically, when you look at the Marcy Avenue station you will find:

So trains that stop at the same physical platform will appear to be stopping at different platforms in the data.

To me, the best solution here depends on what you're doing with the data, and I think adding it as an option as this PR is great.

Bigger picture though, to the best of my knowledge it seems that the most robust way to figure out the direction of a trip is to use the boolean direction ID, rather than string parsing the stop IDs.

cedarbaum commented 1 year ago

Thanks for the context - using direction_id seems like the way to go in my case (good timing along with https://github.com/jamespfennell/transiter/pull/105)!