/railway-planner

Public Transport Modelling and Pathfinding application

Primary LanguagePHP

railwayplanner

This a railway planning webapp. It uses the RAPTOR public transport routing algorithm. I can use any correctly formatted GTFS timetable dataset. In this casem, I used data from the Swiss OpenTransportData platform.

Setup

This server uses Apache2, MySQL 8.0 and PHP 7.2

  1. Add
    default-character-set = utf8mb4
    local_infile=1
    
    [mysql]
    default-character-set = utf8mb4
    
    [mysqld]
    character-set-client-handshake = FALSE
    character-set-server = utf8mb4
    collation-server = utf8mb4_unicode_ci
    local_infile=1
    
    to your my.cnf file (usually under /etc/mysql/my.cnf). This ensures the databases uses utf8 encoding to store text
  2. The data is sourced from the 2020 timetable for the Swiss public transport network in GTFS format, available at the Swiss Transportation Open Data Platform. Download the gtfs .zip file here
  3. In the projet root (the same level as the "sql/" and "html/" directories), create a new folder called "data". In the "data/" folder, create a new folder called "clean", a folder named "config", and a folder named "log".
  4. Extract the gtfs .zip files into the "data/" directory.
  5. Run all python scripts in the "scipts/" folder, these will clean the data, and create .csv files in "data/clean/ that correspond to the database schema. A command that might execute this for you is for f in scripts/*.py; do python "$f"; done. It might take a while.
  6. Create a mysql database and connect to it via the mysql console (something like sudo mysql <name of database> or mysql -u <username> -p <name of database>)
  7. In the console, run the table creation script like so: SOURCE <path to root>/sql/create_tables.sql
  8. Then insert the csv data into the database with SOURCE <path to root>/sql/insert_data.sql. You will have to change the paths to the data files in insert_data.sql. Depending on the dataset used, this will take quite a while to complete (it took ~10 minutes on my machine.
  9. Run the uniquify_routes.sql script, which will modify routes so that every trip on a specific route has the exact same stops. This is needed for the RAPTOR pathfinding algorithm.
  10. Inside "config/", create a file named "db_cfg.ini" with content:
    [database_credentials]
    host = "<database host, usually localhost>"
    user = "<database user>"
    password = "<database user password>"
    database = "<name of database>"
    
  11. On linux, run command chmod -R a+rw log to make the log folder writable to other users
  12. Install composer using sudo apt install composer then in the command line, navigate to the project root
  13. In the project root, run composer require monolog/monolog to install monolog
  14. Redirect apache to the project html root by changing the DocumentRoot line in /etc/apache2/sites-available/000-default.conf and /etc/apache2/sites-enabled/000-default.conf to DocumentRoot <path to root>/railwayplanner/html.