SFTT is a pair of command-line tools for creating simplified train timetables for the UK rail network.
Considering a train route from X to Z, there are two levels of detail you might want:
- "There is a train leaving X at 12:41, which will take 21 minutes to get to Y. Change at Y to board the 13:05 to Z, which takes 8 minutes."
- "It takes about 20 minutes to get from X to Y, then about 10 minutes to get from Y to Z."
SFTT covers case 2. It outputs JSON files which summarise travel times and transfers from all stations to a particular destination. You can then instantly look up approximate travel times from this file.
SFTT's input is a zipped timetable file from National Rail Open Data. Refer to this guide for details on how to obtain this. (The zip should contain files with extensions like .MCA and .ALF.)
This needs quite a lot of dependencies:
- A JAR of OpenTripPlanner 2.x
- An installation of Java capable of running your OpenTripPlanner version
- Ruby 3.4 or above (plus dependencies in the Gemfile)
- R, tested on 4.5.2
- The UK2GTFS package for R:
https://github.com/ITSleeds/UK2GTFS- First, install
remotes:install.packages("remotes") - Then, install the package:
remotes::install_github("ITSleeds/UK2GTFS") - You may need to install various packages on your system - in my experience on RHEL, these were:
cmakelibcurl-develudunits2-develgdal310-devel(and maybegdal310-libs)- I had to create symlinks named
/usr/bin/gdal-config[-64]pointing to/usr/bin/gdal310-config[-64]for one of the package dependency build scripts to detect this correctly
- I had to create symlinks named
proj-develgeos-devel
- First, install
Java is started with 16GB of RAM; on my machine (M1 Pro) any less than this isn't sufficient for OpenTripPlanner to start.
SFTT generates a set of configuration files for OpenTripPlanner. This is mainly handled by the UK2GTFS library, with some post-processing to clean up the data for OpenTripPlanner, and additional generation for walking transfers.
ruby src/sftt/config_generator/main.rb --input [PATH] --output otp-config(Where [PATH] is a directory which contains your timetable zip, named exactly timetable.zip.)
Once you have OpenTripPlanner configuration, SFTT's second step will start it and query for all routes, then dump them into a JSON file.
ruby src/sftt/route_extractor/main.rb ^
--otp-config otp-config ^
--otp-jar ~/Downloads/otp*.jar ^
--to LEEDS
--output LEEDS.json