Comparing version 0.8.5 to 0.8.6
{ | ||
"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", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54659
1015
1