nextbus-to-gtfs-rt
v3.0.0
Published
A script that converts the nextbus api to gtfs-rt
Downloads
6
Maintainers
Readme
nextbus-to-gtfs-rt
A NodeJS translator of the NextBus API to GTFS-RT.
CLI Usage
One-Off Script
node scripts\writer.js [options]
Options:
-a, --agency-id
The NextBus Agency Id [string] [required]
-d, --output-directory
the directory to save files to[string] [default: "./"]
-e, --cache-expiration-time
Number of hours between cache refreshes
[default: 24]
-h, --help
Show help [boolean]
Example:
scripts\writer.js -a sf-muni -d output
This will download the current state of the sf-muni NextBus Feed, translate it to gtfs-rt and save to three files.
Continuous Script
scripts\continuousWriter.js [options]
Options:
-a, --agency-id
The NextBus Agency Id [string] [required]
-d, --output-directory
the directory to save files to
[string] [default: "./"]
-e, --cache-expiration-time
Number of hours between cache refreshes
[default: 24]
-s, --seconds
number of seconds to wait after execution of
previous writer finishes [default: 60]
-h, --help
Show help [boolean]
Example:
scripts\continuousWriter.js -a sf-muni -d output
Download the current state of the sf-muni NextBus Feed, Translate it to gtfs-rt and save to files every minute.
Note:
It is recommended to use the continuous writer in conjuction with the package forever.
Module Usage
var Translator = require('nextbus-to-gtfs-rt')
var translator = new Translator({
nextbusAgencyId: 'sf-muni'
})
Constructor
Takes in an object with the following attributes:
nextbusAgencyId (string, required) String of the NextBus agency id
cacheExpiration (int, optional, default=24) Number of hours between cache refreshes
Translator methods
Each method takes in a callback funtion argument with the signature: funtion(err, feedMessage)
where err
is any error that occurred and feedMessage
is a protobuf object of the gtfs-rt feed for the requested type.
processServiceAlerts
processTripUpdates
processVehiclePositions
License
MIT