Consider transfers.txt
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 24
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
Right now, we only account for direct switches between connections. We should add transfers to the mix to allow routing on a full network.
Transfers come in guaranteed transfers (transfer time == 0) and minimum transfer_time transfers.
Both can be handled the same by storing all transfers for a stop.
We can probably optimise the routing quite a bit, if we identify all reasonable transfer locations in advance.
A transfer is only reasonable at station `x+1` if we can reach an earlier train at `x+1` that we couldn't reach at `x` or can switch to a line that did not exist at `x`. So if `lines(x) != lines(x+1) || \exists(line) : get_earliest_departure(line,x+1) < get_earliest_departure(line,x)`, we consider transferring. This is only the case if some line overtakes another between `x,x+1`. So transfers are necessary only if a line `a` exists that overtakes line `b` between `x,x+1`.
Otherwise we could have done the transfer at `x`.
This allows for an analysis of all stops for possible transfers. We simply scan all lines that are present at `x` and `x-1` and see if the current line overtakes any other line between `x-1` and `x`. If so, or if `x` contains a new line, we mark `x` as transfer location.
Transfers to include:
- [ ] station to station + same stop transfers, if not already part of transfers.txt, given they fulfil any of the following
- [ ] same line: `previous(this) != next(reverse(this))` (the opposing direction services a stop that we did not reach ourselves)
- [ ] new lines become available
- [ ] lines overtake at this stop (stop a and stop b are serviced by two lines, one line reaches a later but b prior to the other line)
- [ ] ensure that ^ covers all required transfers
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting the existing direct-switch routing logic and how transfers.txt is currently represented, if it is present. Compare the implementation with the listed station, same-line, new-line, and overtaking cases; done means all required transfers are included and routing works across the full network.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100