Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gtfs2lc

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gtfs2lc - npm Package Compare versions

Comparing version 0.8.5 to 0.8.6

14

baseUris-example.json
{
"stop" : "http://data.gtfs.org/example/stops/{stop_id}",
"route" : "http://data.gtfs.org/example/routes/{routes.route_id}",
"trip" : "http://data.gtfs.org/example/trips/{trips.trip_id}/{trips.startTime(YYYYMMDDTHHmm)}",
"connection" : "http://example/linkedconnections.org/connections/{trips.startTime(YYYYMMDDTHHmm)}/{connection.departureStop}/{trips.trip_id}"
"stop": "http://data.gtfs.org/example/stops/{stop_id}",
"route": "http://data.gtfs.org/example/routes/{routes.route_short_name}",
"trip": "http://data.gtfs.org/example/trips/{trip_id}/{routes.route_short_name}{trips.startTime}",
"connection": "http://example/linkedconnections.org/connections/{trips.startTime}/{connection.departureStop}/{trips.trip_id}",
"resolve": {
"route_short_id": "connection.trip.route.route_id.substring(0,5)",
"trip_id": "connection.trip.trip_id",
"trip_startTime": "format(connection.trip.startTime, 'YYYYMMDDTHHmm');",
"departureStop": "connection.departureStop"
}
}

@@ -51,3 +51,4 @@ /**

// Set startTime of the trip
trip['startTime'] = startTime;
let tripOfThisConnection = Object.assign({}, trip);
tripOfThisConnection['startTime'] = startTime;

@@ -59,3 +60,3 @@ let connection = {

departureStop: connectionRule['departure_stop'],
trip: trip
trip: tripOfThisConnection
};

@@ -67,5 +68,5 @@

else if (trip['trip_headsign'])
connection['headsign'] = trip['trip_headsign'];
connection['headsign'] = tripOfThisConnection['trip_headsign'];
else if (trip.route['route_long_name'])
connection['headsign'] = trip.route['route_long_name'];
connection['headsign'] = tripOfThisConnection.route['route_long_name'];

@@ -72,0 +73,0 @@ if (connectionRule['arrival_stop_headsign'])

/**
* Pieter Colpaert © Ghent University - iMinds
* Pieter Colpaert © Ghent University - iMinds
* Combines connection rules, trips and services to an unsorted stream of connections

@@ -9,8 +9,10 @@ */

var URIStrategy = function (baseUris) {
var URIStrategy = function(baseUris) {
var defaultBaseUris = {
stop: 'http://example.org/stops/{stop_id}',
route: 'http://example.org/routes/{routes.route_id}',
trip: 'http://example.org/trips/{trips.trip_id}/{trips.startTime(YYYYMMDD)}',
connection: 'http://example.org/connections/{trips.startTime(YYYYMMDD)}/{connection.departureStop}/{trips.trip_id}'
trip:
'http://example.org/trips/{trips.trip_id}/{trips.startTime(YYYYMMDD)}',
connection:
'http://example.org/connections/{trips.startTime(YYYYMMDD)}/{connection.departureStop}/{trips.trip_id}',
};

@@ -38,3 +40,3 @@ if (!baseUris) {

this._connectionTemplate = uri_templates(baseUris.connection);
this._resolve = baseUris.resolve || {};
};

@@ -45,19 +47,19 @@

*/
URIStrategy.prototype.getId = function (connection) {
return resolveURI(this._connectionTemplate, connection);
URIStrategy.prototype.getId = function(connection) {
return resolveURI(this._connectionTemplate, connection, this._resolve);
};
URIStrategy.prototype.getStopId = function (id) {
URIStrategy.prototype.getStopId = function(id) {
return this._stopTemplate.fill({ [this._stopTemplate.varNames[0]]: id });
};
URIStrategy.prototype.getTripId = function (connection) {
return resolveURI(this._tripTemplate, connection);
}
URIStrategy.prototype.getTripId = function(connection) {
return resolveURI(this._tripTemplate, connection, this._resolve);
};
URIStrategy.prototype.getRouteId = function (connection) {
return resolveURI(this._routeTemplate, connection);
}
URIStrategy.prototype.getRouteId = function(connection) {
return resolveURI(this._routeTemplate, connection, this._resolve);
};
function resolveURI(template, connection) {
function resolveURI(template, connection, resolve) {
let varNames = template.varNames;

@@ -67,3 +69,3 @@ let fillerObj = {};

for (let i in varNames) {
fillerObj[varNames[i]] = resolveValue(varNames[i], connection);
fillerObj[varNames[i]] = resolveValue(varNames[i], connection, resolve);
}

@@ -74,3 +76,10 @@

function resolveValue(param, connection) {
function resolveValue(param, connection, resolve) {
// try first to resolve using keys in 'resolve' object
if (resolve[param]) {
return eval(resolve[param]);
}
// otherwise, keep behaviour for backward compatibility
// GTFS source file and attribute name

@@ -77,0 +86,0 @@ let source = param.split('.')[0];

{
"name": "gtfs2lc",
"version": "0.8.5",
"version": "0.8.6",
"description": "Mapping script from gtfs to (linked) connections",

@@ -5,0 +5,0 @@ "main": "lib/gtfs2lc.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc