edward-shen / MMM-MBTA

MagicMirror² module for the Massachusetts Bay Transportation Authority
MIT License
12 stars 4 forks source link

Inbound vs Outbound Bus Routes #14

Closed chris-wei-17 closed 6 years ago

chris-wei-17 commented 6 years ago

Hopefully this is the appropriate place for this type of question. I was able to add a bus route to the module config that was not originally included in the "stations-formatted.json". In this particular case that bus stop is "L St @ Broadway". I noticed when I set it up for subway stations it shows trains going in both directions. For this station, it is only showing outbound (city point) buses. When you look at the route map, the inbound and outbound stops are across the street from each other but have the same name. I didn't see any variables that sounded like they would pick the inbound or outbound routes. Have you encountered this problem? Maybe it is an issue with the information coming from the MBTA? mbta

edward-shen commented 6 years ago

Hey Chris!

Actually, someone brought up a similar question to yours on the MagicMirror Forums. The issue for them was that there was both an outbound and inbound route for a bus stop, but they were only able to select one direction. Turns out, for bus stops, there may be multiple routes (inbound vs outbound) despite having the same name. For MMM-MBTA, it means that they're considered separate locations.

This behavior doesn't occur on subway routes because for whatever reason MBTA sends both inbound and outbound route data for a single station.

To fix this, you'd need to find whatever stop id correlates to the other direction. (Do you also mind posting how you got it to work with another station outside of stations-formatted.json? I'd like to update the list at some point...)

As of right now, adding features to this would be nice but I currently don't have a lot of time nor an accurate testing environment (an actual magic mirror) to work on it.

I hope that answers your question; let me know if you have any others. You're also free to send a PR if you want to improve MMM-MBTA!

chris-wei-17 commented 6 years ago

Edward,

I found a zip file on the MBTA developer page (https://www.mbta.com/developers/gtfs). On that page there is a button - "Download the latest MBTA GTFS feed". This downloaded a zip file with text files full of data and configuration variables. For example, file names "calendar", "facilities', "routes", and "stops", as well as many other. In the "stops" file is a list of IDs, stop names, as well as other stop information that I am not really sure how to use, but also don't think I need. The "0" and "1" may refer to direction and inbound/outbound, but I'm not sure. An example below

"41","41","E Broadway @ L St","","","",42.335658,-71.035628,"","","","",0,"",1

For my specific case I needed the L St stop on East Broadway. Searching through that file, I found a few options. It looks like this stop has a couple names - E Broadway @ L St, and L St @ Broadway. Each name has two different IDs. To get the desired direction to show up, it was simply a matter of inserting the right ID number along with the station name into stations-formatted.json. Since the name has two IDs, and I assume there would be some confusion if you listed the same name twice, there was a trial and error to find which ID to use in the file. Each ID corresponds to one side of the street (route) or the other, as you stated.

Once I found the desired stop in the MBTA file, I found the proper location for the stop alphabetically in stations-formatted and added a line with the important information. I actually should have been able to figure out how to do this, as I forgot to add the new stops/IDs to the .json on my later attemps and your response reminded me of that oversight. However, now we have an explanation for anyone else who is looking. I've attached the stops file to this response, but anyone looking for it should be able to find it on the gtfs website as well

stops.txt

edward-shen commented 6 years ago

Thanks so much for your contribution!

I'll be closing this issue now, but feel free to continue the discussion!