Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more bus routes to tracking #86

Open
30 of 48 tasks
devinmatte opened this issue Jun 9, 2024 · 6 comments
Open
30 of 48 tasks

Add more bus routes to tracking #86

devinmatte opened this issue Jun 9, 2024 · 6 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@devinmatte
Copy link
Member

devinmatte commented Jun 9, 2024

YEAR OF THE BUS, let's add a bunch more of the bus routes that don't share a schedule with any other bus routes

  • line-7
  • line-8
  • line-10
  • line-11
  • line-14
  • line-18
  • line-26
  • line-29
  • line-30
  • line-31
  • line-35
  • line-36
  • line-37
  • line-38
  • line-42
  • line-43
  • line-44
  • line-51
  • line-100
  • line-101
  • line-105
  • line-106
  • line-108
  • line-110
  • line-112
  • line-119
  • line-134
  • line-195
  • line-215
  • line-230
  • line-236
  • line-238
  • line-240
  • line-354
  • line-429
  • line-455
  • line-69
  • line-80
  • line-83
  • line-87
  • line-88
  • line-90
  • line-93
  • line-94
  • line-95
  • line-96
  • line-97
  • line-99
@devinmatte devinmatte added the good first issue Good for newcomers label Jun 9, 2024
@devinmatte devinmatte moved this to In Progress in Good First Tasks Jun 10, 2024
@devinmatte devinmatte self-assigned this Jun 10, 2024
@MoralCode
Copy link
Contributor

Is there a particular process you followed to add those bus routes? it looks to me like that constants file is just a mapping of bus route numbers to stop numbers. Is this something that has to be manually figured out by physical visit?

@devinmatte
Copy link
Member Author

Nope, if you reference other PRs that's all you need. Gobble is the first step to adding it to the dashboard. There is more complex work that requires AWS access before it goes live in the dashboard, but we can't do that until ~1 month after gobble changes merged

@MoralCode
Copy link
Contributor

MoralCode commented Jun 27, 2024

so for example to add line 100 i would go to https://www.mbta.com/schedules/100/line and make a dictionary of all the stop IDs on that line?

I was going to use line 7 as an example but it seems like the stops have changed since your PR - the website shows 18 stops and the dict has less than that. Is this something that should be kept up to date/in sync with what the MBTA website says?

@MoralCode
Copy link
Contributor

MoralCode commented Jun 27, 2024

if that method is in fact how these constants are added (and if they should be kept up to date) it seems as though these constants aren't really constant. In which case I have found a way to fetch this data using MBTAs own API (the same api that webpage uses).

curl 'https://www.mbta.com/schedules/line_api?id=7&direction_id=0&route_pattern=7-2-0' --compressed | jq '{ids: [.route_stop_lists[][] | .station_info.id]} this will return a JSON object like this:

{
  "ids": [
    "16535",
    "6564",
    "888",
    "889",
    "244",
    "246",
    "208",
    "885",
    "33"
  ]
}

@MoralCode
Copy link
Contributor

MoralCode commented Jun 27, 2024

update:

i have found a way to just grab all the route patterns for a given bus line (not just the one that you happen to know the identifier of - and even ones not shown on the site) and the stop ids for that pattern (as well as the rest of the data but for this simple script i'm just ignoring that data)

output sample from this improved script as run on bus line 101: 101-patterns.json

@MoralCode
Copy link
Contributor

existing_route_constants.json
new_routes_constants.json

Here is the JSON data from all the routes that have been checked off (existing) and not yet checked off (new) in this PR (except line 195 which i noticed has no routes). Both files should be in the same data format as the constants.py file in this PR.

Once I have a better understanding of whether it would be helpful, I'd be happy to integrate the code that generated these into the main gobble script so it can automatically grab all the stops (or just the stops on the typical route) for all the bus lines on startup to ensure that the data feeding the rest of the TransitMatters dashboards is as complete as possible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
Status: In Progress
Development

No branches or pull requests

2 participants