Skip to content
chosak edited this page Jan 26, 2012 · 6 revisions

Transit Near Me can import transit data provided in the General Transit Feed Specification (GTFS) format. Transit agencies usually provide this data in the form of a single .zip archive file.

Importing GTFS

TNM includes a Django management command, gtfsimport, for importing GTFS archive data. After installing the application via the instructions provided here, enter the following command:

./manage.py gtfsimport gtfs_archive.zip dataset_name

The archive.zip argument should be the full path to the local archive file, and the dataset_name argument should be a descriptive name. For example, if the archive file was provided by the Washington Metropolitan Area Transit Authority, you might choose to name this dataset "WMATA".

Running this command will import into your database those parts of the GTFS dataset required by Transit Near Me. Run the command multiple times, once for each dataset you wish to import.

TNM also includes a management command for patching GTFS datasets with ESRI shapefiles. This may be necessary, for example, if a GTFS archive lacks shape information or contains erroneous information. For more information, see:

./manage.py gtfspatch --help

Configuring real-time APIs

Transit Near Me has the ability to pull real-time bus and train predictions from transit agency APIs that support that functionality. Enabling this functionality requires first configuring APIs via the Django settings file, then pulling in a list of predictable stops from those APIs, and finally syncing API stops with stops defined in existing GTFS datasets. This last step is done via the builddb command, as described below.

API configuration is done via the TRANSIT_APIS setting in the project's local_settings.py file. See the wiki page on Django settings for more details on how to configure this setting.

Once the APIs of interest have been configured, run the following command to connect to them and pull down a list of predictable stops:

./manage.py refreshstops

This command populates a database table with a list of predictable stops and associates them with their respective API for later use.

Building the TNM database

Transit Near Me converts data loaded from GTFS archives into its own set of database tables that are more optimized for access via the web. Another Django management command, builddb, is provided for this purpose. Once all GTFS datasets have been loaded into the database, run:

./manage.py builddb

Note that while running this command will wipe out any previously computed TNM data, it will not affect the GTFS data tables. This process may also take a few minutes to complete.

If real-time APIs have been configured, and the refreshstops command has been run as described above, this command will also attempt to link APIs with TNM stops.

Clone this wiki locally