nextbus-to-gtfs-rt

3.0.0 • Public • Published

nextbus-to-gtfs-rt

npm version Build Status Dependency Status Test Coverage

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

/nextbus-to-gtfs-rt/

    Package Sidebar

    Install

    npm i nextbus-to-gtfs-rt

    Weekly Downloads

    1

    Version

    3.0.0

    License

    MIT

    Last publish

    Collaborators

    • evansiroky