Repository navigation
Conversation
On Interrail, the page downloads every operator's trip bundle from train-api (/v2/) into a worker and searches them with train-api's journey engine. The exact trip (one way, round trip, flexible days) and explore from a station read its results; a train of another operator books on that operator's site. When the bundles can't load, Interrail searches SNCF's trains alone.
…request The Europe worker now downloads every operator's station list for the directory and, per search, only the trip bundles of the operators on the way. Settings gains an opt-in offline mode that keeps every operator's files in Cache Storage and searches from them when train-api can't be reached.
Same change as train-api's engine: Munich's place no longer takes the name of the tram stop "Hauptbahnhof (U, Tram)".
Same change as train-api's engine.
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: on Interrail, Railmap searched SNCF's trains only. Paris to Madrid, Amsterdam or Zurich found nothing past the border, and #101 added Renfe by hand.
After: on Interrail, Railmap searches every operator train-api publishes, on the device. An exact trip (one way, round trip, flexible days) finds journeys that change between operators, such as Paris to Madrid with a TGV to Barcelona and then an AVE. Explore from a station lists the towns reachable across Europe. Every station these operators serve is in the station fields and on the map. A Renfe, DB or NS train books on that operator's site ("Book on Renfe") and carries no reservation fee.
It scales by downloading only what a search needs. On a visit the app loads every operator's station list, which is small. Each search then loads only the timetables of the operators on the way: Paris to Madrid loads SNCF and Renfe, never Finland. Settings gains an opt-in "Europe's timetables offline" switch that keeps every country on the device and searches from that copy when there is no connection.
This replaces #101, so #101 can be closed. It needs train-api #14 and #15 merged and deployed. Until
/v2/is published, or whenever it can't be reached and no offline copy is kept, Interrail searches SNCF's trains alone, exactly as before.How:
src/europe/engine.tsis a copy of train-api'ssrc/search.ts, with no imports. It matches stations across operators by position and name, groups them into towns, and runs a connection scan.src/europe/network.tsbuilds the station directory from every operator'sstations.json.amsterdam-centraal). SNCF's stations get their positions from the app's own station list.operatorsForpicks the operators a search needs. Two operators count as linked when they serve the same town. A trip uses every operator on a shortest chain of linked operators between its two towns, or on a chain one operator longer. Explore uses the origin's operators and their neighbours.src/europe/europe.worker.tsandclient.tsload the files and answer searches. Searches the user just asked for go ahead of background work.railmap-europe) and is read from there when the network fails. A sync on each visit re-downloads only when train-api's index is newer. Turning it off deletes the copy.public/sw.jsleaves that cache alone and no longer caches/v2/files itself. The cache name is bumped so the new service worker installs.findJourneysreads the cached journeys first, throughsetJourneySource. The trip list, the calendars and the round-trip return lists use them without other changes. A route the network doesn't serve falls back to SNCF's trains.src/data/operators.ts, and booking sites come from train-api's index.Tests:
tests/europe.test.tscovers:findJourneyssource, operators and the registry.npm test(253 tests), build, prerender, generate-pages, verify andtest:e2e(27/27) pass locally.