https://github.com/adrianprelipcean/pgtfs
  
  
    PostgreSQL Extension for public transportation routing using GTFS 
    https://github.com/adrianprelipcean/pgtfs
  
geospatial gtfs postgresql-extension public-transportation routing
        Last synced: 1 day ago 
        JSON representation
    
PostgreSQL Extension for public transportation routing using GTFS
- Host: GitHub
- URL: https://github.com/adrianprelipcean/pgtfs
- Owner: adrianprelipcean
- Created: 2024-04-11T07:49:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-19T11:59:41.000Z (over 1 year ago)
- Last Synced: 2024-04-20T11:49:14.678Z (over 1 year ago)
- Topics: geospatial, gtfs, postgresql-extension, public-transportation, routing
- Language: C++
- Homepage:
- Size: 34.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- 
            Metadata Files:
            - Readme: readme.md
- License: LICENSES/CC-BY-NC-SA-4.0.txt
 
Awesome Lists containing this project
README
          
# PGTFS
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.
## Features
- 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.
## Documentation and tutorials
Official documentation is available at [https://adrianprelipcean.github.io/pgtfs/](https://adrianprelipcean.github.io/pgtfs/)
Tutorials are available at [https://github.com/adrianprelipcean/pgtfs-tutorials](https://github.com/adrianprelipcean/pgtfs-tutorials)
## Installation
### On your local environment
1. Clone the PGTFS repository:
    ```sh
    git clone https://github.com/adrianprelipcean/pgtfs.git
    ```
2. Install the server development packages (e.g., for Ubuntu):
    ```sh
    apt-get install postgresql-server-dev-all
    ```
3. Build and install the extension:
    ```sh
    cd pgtfs
    make && make install
    ```
4. Enable the extension in your PostgreSQL database:
    ```sql
    CREATE EXTENSION pgtfs;
    ```
### Using Docker
1. Build the Docker container
    ```sh
    docker build -t gtfs/db:1.0 . 
    ```
2. Run the image 
    ```sh
    docker run --name gtfs-container -d -p 15432:5432 --env-file=.env -v `pwd`/docs:/docs gtfs/db:1.0
    ```
3. Enable the extension 
    ```sh
    psql --host localhost --port 15432 --user postgres -c "CREATE EXTENSION pgtfs;"
    ```
4. Verify that the extension is enabled 
    ```sh
    psql --host localhost --port 15432 --user postgres -c "SELECT * FROM pgtfs_version();"
    ```
## Generating the documentation
Easiest way to generate the documentation is to use Docker
```sh
docker exec -it gtfs-container bash -c "doxygen Doxygen && sphinx-build docs/ docs/_build/ -a"
```
## Important notes 
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 
License information is found in the [LICENSES](./LICENSES/) folder.