Repository navigation
Conversation
src/search.ts finds journeys with changes across every operator loaded: stations are matched by coordinates (by name where a source has none), a town's stations are grouped so a change can cross town, and a connection scan with one label per number of trains finds the earliest arrival for each number of changes. It has no imports, so it runs in a browser worker on downloaded bundles as well as in Node. npm run search searches from the command line, on the published bundles or a folder of them. src/server.ts serves /v2/places and /v2/journeys with no key, and the Dockerfile runs it anywhere containers run.
…est station Network.reachable() runs the scan from each hour of the day and keeps, for every place reached, the shortest journey: the explore view of an app, and GET /v2/reachable on the API. placeIndex() finds the place of an operator's own station name, so a client can map its stations onto the search's. A place that merges several stations is now named and placed after the one most trips call at (Madrid-Puerta de Atocha rather than its suburban platforms).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before: train-api publishes timetables only. Finding Madrid to Amsterdam means matching each operator's station names by hand and joining the trains yourself.
After:
src/search.tsfinds journeys with changes across every operator on the v2 trip bundles, and lists every place reachable from one on a day. The same file runs three ways:npm run search -- paris madrid 2026-10-12.Dockerfileserves/v2/places,/v2/journeysand/v2/reachablewith no key and CORS open.Stacked on #14 (the bundles).
How:
tgvmax), they're matched by name. A place is named after its busiest located station, and carries how many trips call there (calls) so clients can rank places.reachable()runs the scan with no target from each departure slot (every hour by default) and keeps the fastest journey to each place.placeIndex()finds an operator's station by its own name.src/load.tsloads bundles from a URL or a folder.src/server.tsis the API, andscripts/search.tsis the CLI.Checks:
npm run checkpasses with 57 tests. 12 cover the engine: matching, naming, towns, changes across three operators, overnight trains, time zones, reachable places and lookups. The rest cover the loader and the API. The fixture build, the CLI and the server were also run locally.