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

Filter departures and arrivals by line id #51

Open
RBeerDevelopment opened this issue Oct 26, 2022 · 2 comments
Open

Filter departures and arrivals by line id #51

RBeerDevelopment opened this issue Oct 26, 2022 · 2 comments

Comments

@RBeerDevelopment
Copy link

Currently the /stops/:id/departures and the /stops/:id/arrivals only take the direction and the duration as filter arguments.
However, sometimes it would also be interesting (or easier) to filter by a specific line (eg. ?line=u5) or do this in addition to the existing filters.

@derhuerst
Copy link
Owner

derhuerst commented Oct 27, 2022

This is tricky, because the VBB HAFAS API used by vbb-rest

  • …doesn't necessarily support a "line ID" that matches what people would intuitively call a "line" (e.g. S8, M8 or X1). – Instead, a "line" seems to be a group of trips grouped under a name in the schedule data that HAFAS has been fed with; So wether the "lines" make sense seems to depend on the structure of VBB internal schedule data.
  • …currently doesn't return those HAFAS "line IDs", even though e.g. the Deutsche Bahn HAFAS API does.

Also, even if the VBB HAFAS API returned proper line IDs, hafas-client wouldn't parse & expose them (just as id with fallback to slugg(name), which is not usable for filtering):

https://github.com/public-transport/hafas-client/blob/f530a30fe019f3c8e19a4eb0f15fa99776db6f7e/parse/line.js#L8-L20

But hafas-client already supports filtering by such "line IDs":

https://github.com/public-transport/hafas-client/blob/f530a30fe019f3c8e19a4eb0f15fa99776db6f7e/index.js#L60

Let's wait until the VBB HAFAS API returns them, then we can implement this for vbb-rest.

@derhuerst
Copy link
Owner

In any case, having this filtering by "line ID" in hafas-rest-api would be beneficial for all HAFAS APIs that return them – specifically, db-rest would gain this functionality. If you want to implement this, please submit a Pull Request! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants