Status: not functional - work in progress
This javascript library transforms a stream of "arrivals and departures" to "connections".
This code is useful for route planning applications where arrivals and departures are easy to generate, but connections are difficult to get right in the same processing.
npm install -g arrdep2connections
Now you can use the code on top of 2 files which follow the JSON-LD stream specification:
arrdep2connections arrivalsfile.json departurefile.json -i context.json > connections.json
Optionally, you can specify a different inbound context.json
using the -i
flag, and a different outbound context by using the -o
flag.
Install it using npm:
npm install --save arrdep2connections
Use it in your code:
var arrdep2connections = require('arrdep2connections');
var stringify = require('JSONStream').stringify(false);
departureStream.pipe(arrdep2connections(arrivalStream)).pipe(stringify).pipe(process.stdout);
A departure is something of this form:
{
"date" : "2015-12-25",
"departureTime" : "23:49",
"stop" : "{stop1}",
"other properties" : "other values"
}
Explanation:
property | URI | description | type |
---|---|---|---|
date | dcterms:date | date when the trip of the vehicle departed | a day in ISO8601 format or xsd:date |
departureTime | gtfs:departureTime | departure time given as a duration calculated starting at noon minus 12h in this format "hh:mm" | iso8601 or xsd:duration |
stop | gtfs:stop | stop of departure | an identifier of the stop of departure |
other properties | Feel free to add anything on here. When properties overlap with an arrival, only the property from the departure is kept in the connection. |
An Arrival is something of this form:
{
"date" : "2015-12-25",
"arrivalTime" : "24:16",
"stop" : "{stop2}",
"other properties" : "other values"
}
Explanation:
property | URI | description | type |
---|---|---|---|
date | dcterms:date | date when the trip of the vehicle departed | a day in ISO8601 format or xsd:date |
arrivalTime | gtfs:arrivalTime | arrival time given as a duration calculated starting at noon minus 12h in this format "hh:mm" | iso8601 or xsd:duration |
stop | gtfs:stop | stop of arrival | an identifier of the stop of arrival |
other properties | Feel free to add anything on here. When properties overlap with a departure, only the property from the departure is kept in the connection. |
A connection object is something that looks like this:
{
"departureTime" : "2015-12-25T23:49",
"departureStop" : "{stop1}",
"arrivalTime" : "2015-12-26T00:16",
"arrivalStop" : "{stop2}",
"other properties" : "other values"
}
Explanation:
property | URI | description | type |
---|---|---|---|
arrivalTime | lc:arrivalTime | arrival date/time | iso8601 or xsd:dateTime |
arrivalStop | lc:arrivalStop | stop of arrival | an identifier of the stop of arrival |
departureTime | lc:departureTime | departure date/time | iso8601 or xsd:dateTime |
departureStop | lc:departureStop | stop of departure | an identifier of the stop of departure |
other properties | copied properties from the arrival/departure objects |