Project Awesome project awesome

GTFS Realtime Utilities > gtfs-rt-differential-to-full-dataset

Javascript tool to transform a continuous GTFS Realtime stream of DIFFERENTIAL incrementality data into a FULL_DATASET dump.

Package 5 stars GitHub

gtfs-rt-differential-to-full-dataset

Transform a continuous GTFS Realtime (GTFS-RT) stream of DIFFERENTIAL incrementality data into a FULL_DATASET dump.

Note: Right now, this package does not obey the draft DIFFERENTIAL spec exactly. See below and #1 for details.

npm version build status ISC-licensed support me via GitHub Sponsors chat with me on Twitter

Installing

npm install gtfs-rt-differential-to-full-dataset

Usage

const {
	gtfsRtDifferentialToFullDataset,
} = require('gtfs-rt-differential-to-full-dataset')

const toFull = gtfsRtDifferentialToFullDataset({
	ttl: 2 * 60 * 1000, // 2 minutes
})
toFull.on('error')

differentialFeedMessages.pipe(toFull)
setInterval(() => {
	console.log(toFull.asFeedMessage())
}, 5000)

toFull will be a writable stream in object mode that expects JS objects in the FeedMessage structure/format.

toFull.asFeedMessage() returns a protocol-buffer-encoded FULL_DATASET-mode FeedMessage with all FeedEntitys from the DIFFERENTIAL-mode FeedMessages that have been written into toFull so far, as long as they're still relevant.

toFull.nrOfEntities() returns the number of FeedEntitys that are currently part of the FeedMessage.

Contributing

If you have a question or have difficulties using gtfs-rt-differential-to-full-dataset, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.

Back to Transit