PGTFS is a PostgreSQL extension designed to facilitate routing on top of the GTFS (General Transit Feed Specification) format. It provides functionality to query and analyze public transportation data stored in a PostgreSQL database using GTFS feeds.
- Perform routing and journey planning using the Connection Scan Algorithm (CSA).
- Easily integrate public transportation data into your PostgreSQL-based applications.
- Similar interface to pgRouting.
Note: This is still a work in progress, and is not ready for production at this stage.
Official documentation is available at https://adrianprelipcean.github.io/pgtfs/
Tutorials are available at https://github.com/adrianprelipcean/pgtfs-tutorials
-
Clone the PGTFS repository:
git clone https://github.com/adrianprelipcean/pgtfs.git
-
Install the server development packages (e.g., for Ubuntu):
apt-get install postgresql-server-dev-all
-
Build and install the extension:
cd pgtfs make && make install
-
Enable the extension in your PostgreSQL database:
CREATE EXTENSION pgtfs;
-
Build the Docker container
docker build -t gtfs/db:1.0 .
-
Run the image
docker run --name gtfs-container -d -p 15432:5432 --env-file=.env -v `pwd`/docs:/docs gtfs/db:1.0
-
Enable the extension
psql --host localhost --port 15432 --user postgres -c "CREATE EXTENSION pgtfs;"
-
Verify that the extension is enabled
psql --host localhost --port 15432 --user postgres -c "SELECT * FROM pgtfs_version();"
Easiest way to generate the documentation is to use Docker
docker exec -it gtfs-container bash -c "doxygen Doxygen && sphinx-build docs/ docs/_build/ -a"
There are a couple drawbacks for the CSA implementation, in particular:
- routing is performed exclusively on trips, so information such as footpaths is not considered
- the SQL query that retrieves the information from
stop_times
needs to be ordered - CSA is an earliest arrival time algorithm, which means it does not prioritize same trip routes
- it is still a work in progress, and not production ready
License information is found in the LICENSES folder.