Displays vehicle data from a GTFS (General Transit Feed Specification) Realtime feed on a map. The map uses a Google Maps basemap with the traffic layer turned on.
Uses GTFS Static to provide vehicle type and direction data. GTFS Static data must be first stored in a database, while the Realtime data can be queried directly from an API provided by the transit provider.
The application has only been tested with the Translink South East QLD feed.
See db
for SQL scripts to create tables, insert data (MySQL scripts for bulk loading data) and creating indexes for GTFS Static data.
Note: drop indexes before bulk loading data.
For MySQL 8+, allow local infile: SET GLOBAL local_infile=1;
Environment variables can either be supplied via command line or put in a .env
file.
- REALTIME_URL: GTFS Realtime URL, e.g. https://gtfsrt.api.translink.com.au/api/realtime/SEQ/VehiclePositions
- DB_CLIENT: Knex database client, e.g. mysql
- DB_HOST: Database server, e.g. localhost
- DB_USER: Database user
- DB_PASSWORD: Database user password
- DB_DATABASE: Database name, e.g. translink_gtfs
- PORT: Port to run Node.js server, e.g. 3000
The browser supports the following query strings
- routes: comma-delimited set of routes that would match the
route_short_name
of a trip. If omitted, then all vehicles are displayed; however, GTFS Static data is not queried from the database for performance reasons. - lat: initial latitude of the map center. If omitted, uses HTML5 geolocation and if not available, defaults to Brisbane, Australia.
- lng: initial longitude of the map center. If omitted, uses HTML5 geolocation and if not available, defaults to Brisbane, Australia.
- z: initial zoom level of the map.
- traffic: "on" or "off" to enable/disable traffic layer on startup
In development, start the server with npm start
and visit http://localhost:3000.