From 151a982606aa06205bedd4032ed73a72a3008811 Mon Sep 17 00:00:00 2001 From: rahls7 Date: Tue, 29 Oct 2019 15:43:34 -0400 Subject: [PATCH 1/5] WIP: add pathways --- gtfs.js | 68 +++++++++++++++++++++++++++++++++++++++++++++++ helpers/schema.js | 15 +++++++++++ 2 files changed, 83 insertions(+) diff --git a/gtfs.js b/gtfs.js index 3a445f5..bdddaa1 100644 --- a/gtfs.js +++ b/gtfs.js @@ -1620,6 +1620,74 @@ class Gtfs { */ setIndexedTransfers(indexedTransfers) { setTable(this, 'transfers', indexedTransfers); } + /* pathways.txt */ + + /** + * Adds a pathway in the GTFS. + * + * @param {Object} pathway Pathway to add in the GTFS. + */ + addPathway(pathway) { addItems(this, 'pathways', [pathway]); } + + /** + * Adds a list of pathways in the GTFS. + * + * @param {Array.} pathways Array of transfers to add in the GTFS. + */ + addPathways(pathways) { addItems(this, 'pathways', pathways); } + + /** + * Apply a function to each pathway in the GTFS. + * + * @param {function} iterator Function which will be applied on every pathway. + */ + forEachPathway(iterator) { forEachItem(this, 'pathways', iterator); } + + /** + * Get the indexed pathways of the GTFS. The indexation is defined in the schema (see schema.js). + * + * @return {Map.>} Indexed transfers. + */ + getIndexedPathways() { return getIndexedTable(this, 'pathways'); } + + /** + * Get a pathway using its indexes: the fromStopId and the toStopId. + * + * @param {string} pathwayId First index of the pathway + * @return {Object} Pathway object + */ + getPathwayWithPathwayId(pathwayId) { + return getters.getItemWithIndexes(pathwayId, 'pathways', this); + } + + /** + * Removes a pathway of the GTFS. + * + * @param {Object} pathway Pathway to remove of the GTFS. + */ + removePathway(pathway) { removeItems(this, 'pathways', [pathway]); } + + /** + * Removes a list of pathways of the GTFS. + * + * @param {Array.} pathways Pathways to remove of the GTFS. + */ + removePathways(pathways) { removeItems(this, 'pathways', pathways); } + + /** + * Reset the map of indexed pathways. + */ + resetPathways() { resetTable(this, 'pathways'); } + + /** + * Set the map of indexed transfers. + * + * WARNING: The Map should be indexed as defined in schema.js + * + * @param {Map.>} indexedPathways Map of pathways properly indexed (see schema.js). + */ + setIndexedPathways(indexedPathways) { setTable(this, 'pathways', indexedPathways); } + /* feed_info.txt */ diff --git a/helpers/schema.js b/helpers/schema.js index a45938b..0d30583 100644 --- a/helpers/schema.js +++ b/helpers/schema.js @@ -119,6 +119,20 @@ const keysByTableName = { 'transfer_type', 'min_transfer_time', ], + pathways: [ + 'pathway_id', + 'from_stop_id', + 'to_stop_id', + 'pathway_mode', + 'is_bidirectional', + 'length', + 'traversal_time', + 'stair_count', + 'max_slope', + 'min_width', + 'signposted_as', + 'reversed_signposted_as', + ], feed_info: [ 'feed_publisher_name', 'feed_publisher_url', @@ -142,6 +156,7 @@ const indexKeysByTableName = { trips: { indexKey: 'trip_id' }, shapes: { firstIndexKey: 'shape_id', secondIndexKey: 'shape_pt_sequence' }, transfers: { firstIndexKey: 'from_stop_id', secondIndexKey: 'to_stop_id' }, + pathways: { firstIndexKey: 'pathway_id'}, feed_info: { singleton: true }, }; From d5d52ded4721137c48fac014dc3e15f8029320ba Mon Sep 17 00:00:00 2001 From: rahls7 Date: Wed, 30 Oct 2019 11:50:27 -0400 Subject: [PATCH 2/5] Fix: schema --- helpers/schema.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers/schema.js b/helpers/schema.js index 0d30583..c00ea49 100644 --- a/helpers/schema.js +++ b/helpers/schema.js @@ -156,7 +156,7 @@ const indexKeysByTableName = { trips: { indexKey: 'trip_id' }, shapes: { firstIndexKey: 'shape_id', secondIndexKey: 'shape_pt_sequence' }, transfers: { firstIndexKey: 'from_stop_id', secondIndexKey: 'to_stop_id' }, - pathways: { firstIndexKey: 'pathway_id'}, + pathways: { indexKey: 'pathway_id'}, feed_info: { singleton: true }, }; From 2fa3319192e360541986b6c4f53dba60673584d5 Mon Sep 17 00:00:00 2001 From: rahls7 Date: Mon, 11 Nov 2019 17:32:03 -0500 Subject: [PATCH 3/5] WIP: pathways --- helpers/schema.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/helpers/schema.js b/helpers/schema.js index c00ea49..5cc37af 100644 --- a/helpers/schema.js +++ b/helpers/schema.js @@ -26,7 +26,7 @@ const keysByTableName = { 'parent_station', 'stop_timezone', 'wheelchair_boarding', - 'tts_stop_name' + 'tts_stop_name', ], routes: [ 'route_id', @@ -40,7 +40,7 @@ const keysByTableName = { 'route_text_color', 'route_sort_order', 'tts_route_short_name', - 'tts_route_long_name' + 'tts_route_long_name', ], trips: [ 'route_id', @@ -120,18 +120,18 @@ const keysByTableName = { 'min_transfer_time', ], pathways: [ - 'pathway_id', - 'from_stop_id', - 'to_stop_id', - 'pathway_mode', - 'is_bidirectional', - 'length', - 'traversal_time', - 'stair_count', - 'max_slope', - 'min_width', - 'signposted_as', - 'reversed_signposted_as', + 'pathway_id', + 'from_stop_id', + 'to_stop_id', + 'pathway_mode', + 'is_bidirectional', + 'length', + 'traversal_time', + 'stair_count', + 'max_slope', + 'min_width', + 'signposted_as', + 'reversed_signposted_as', ], feed_info: [ 'feed_publisher_name', @@ -156,7 +156,7 @@ const indexKeysByTableName = { trips: { indexKey: 'trip_id' }, shapes: { firstIndexKey: 'shape_id', secondIndexKey: 'shape_pt_sequence' }, transfers: { firstIndexKey: 'from_stop_id', secondIndexKey: 'to_stop_id' }, - pathways: { indexKey: 'pathway_id'}, + pathways: { indexKey: 'pathway_id' }, feed_info: { singleton: true }, }; From 3c1aa427d58549004ea5186608177969ccc9fd88 Mon Sep 17 00:00:00 2001 From: rahls7 Date: Fri, 15 Nov 2019 12:20:28 -0500 Subject: [PATCH 4/5] Feat: Add test cases --- gtfs.js | 2 +- package-lock.json | 500 +++++++++++++------------- tests/samples/1/pathways.txt | 3 + tests/test_generic_table_functions.js | 2 +- tests/test_pathways.js | 103 ++++++ 5 files changed, 358 insertions(+), 252 deletions(-) create mode 100644 tests/samples/1/pathways.txt create mode 100644 tests/test_pathways.js diff --git a/gtfs.js b/gtfs.js index bdddaa1..67b4dc9 100644 --- a/gtfs.js +++ b/gtfs.js @@ -1657,7 +1657,7 @@ class Gtfs { * @return {Object} Pathway object */ getPathwayWithPathwayId(pathwayId) { - return getters.getItemWithIndexes(pathwayId, 'pathways', this); + return getters.getItemWithIndex(pathwayId, 'pathways', this); } /** diff --git a/package-lock.json b/package-lock.json index 068d5ed..126fdbe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,9 @@ { "name": "@transit/gtfs", - "version": "3.4.8", + "version": "3.6.0", "lockfileVersion": 1, "requires": true, "dependencies": { - "acomb": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/acomb/-/acomb-1.2.2.tgz", - "integrity": "sha1-SmBNVyD5kpZF1jGEnVBt6zzzKjw=" - }, "acorn": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.3.0.tgz", @@ -21,7 +16,7 @@ "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", "dev": true, "requires": { - "acorn": "^3.0.4" + "acorn": "3.3.0" }, "dependencies": { "acorn": { @@ -38,8 +33,8 @@ "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", "dev": true, "requires": { - "co": "^4.6.0", - "json-stable-stringify": "^1.0.1" + "co": "4.6.0", + "json-stable-stringify": "1.0.1" } }, "ajv-keywords": { @@ -72,7 +67,7 @@ "integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=", "dev": true, "requires": { - "sprintf-js": "~1.0.2" + "sprintf-js": "1.0.3" } }, "array-union": { @@ -81,7 +76,7 @@ "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", "dev": true, "requires": { - "array-uniq": "^1.0.1" + "array-uniq": "1.0.3" } }, "array-uniq": { @@ -107,7 +102,7 @@ "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", "requires": { - "lodash": "^4.14.0" + "lodash": "4.17.11" } }, "babel-code-frame": { @@ -116,9 +111,9 @@ "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", "dev": true, "requires": { - "chalk": "^1.1.3", - "esutils": "^2.0.2", - "js-tokens": "^3.0.2" + "chalk": "1.1.3", + "esutils": "2.0.2", + "js-tokens": "3.0.2" } }, "balanced-match": { @@ -133,7 +128,7 @@ "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", "dev": true, "requires": { - "balanced-match": "^1.0.0", + "balanced-match": "1.0.0", "concat-map": "0.0.1" } }, @@ -155,7 +150,7 @@ "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", "dev": true, "requires": { - "callsites": "^0.2.0" + "callsites": "0.2.0" } }, "callsites": { @@ -170,9 +165,9 @@ "integrity": "sha1-TQJjewZ/6Vi9v906QOxW/vc3Mkc=", "dev": true, "requires": { - "assertion-error": "^1.0.1", - "deep-eql": "^0.1.3", - "type-detect": "^1.0.0" + "assertion-error": "1.0.2", + "deep-eql": "0.1.3", + "type-detect": "1.0.0" } }, "chalk": { @@ -181,11 +176,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" } }, "circular-json": { @@ -200,7 +195,7 @@ "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", "dev": true, "requires": { - "restore-cursor": "^1.0.1" + "restore-cursor": "1.0.1" } }, "cli-width": { @@ -239,9 +234,9 @@ "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", "dev": true, "requires": { - "inherits": "^2.0.3", - "readable-stream": "^2.2.2", - "typedarray": "^0.0.6" + "inherits": "2.0.3", + "readable-stream": "2.3.3", + "typedarray": "0.0.6" } }, "contains-path": { @@ -262,7 +257,7 @@ "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", "dev": true, "requires": { - "es5-ext": "^0.10.9" + "es5-ext": "0.10.37" } }, "debug": { @@ -302,13 +297,13 @@ "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", "dev": true, "requires": { - "globby": "^5.0.0", - "is-path-cwd": "^1.0.0", - "is-path-in-cwd": "^1.0.0", - "object-assign": "^4.0.1", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "rimraf": "^2.2.8" + "globby": "5.0.0", + "is-path-cwd": "1.0.0", + "is-path-in-cwd": "1.0.0", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1", + "rimraf": "2.6.2" } }, "diff": { @@ -323,7 +318,7 @@ "integrity": "sha512-y0tm5Pq6ywp3qSTZ1vPgVdAnbDEoeoc5wlOHXoY1c4Wug/a7JvqHIl7BTvwodaHmejWkK/9dSb3sCYfyo/om8A==", "dev": true, "requires": { - "esutils": "^2.0.2" + "esutils": "2.0.2" } }, "error-ex": { @@ -332,7 +327,7 @@ "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", "dev": true, "requires": { - "is-arrayish": "^0.2.1" + "is-arrayish": "0.2.1" } }, "es5-ext": { @@ -341,8 +336,8 @@ "integrity": "sha1-DudB0Ui4AGm6J9AgOTdWryV978M=", "dev": true, "requires": { - "es6-iterator": "~2.0.1", - "es6-symbol": "~3.1.1" + "es6-iterator": "2.0.3", + "es6-symbol": "3.1.1" } }, "es6-iterator": { @@ -351,9 +346,9 @@ "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", "dev": true, "requires": { - "d": "1", - "es5-ext": "^0.10.35", - "es6-symbol": "^3.1.1" + "d": "1.0.0", + "es5-ext": "0.10.37", + "es6-symbol": "3.1.1" } }, "es6-map": { @@ -362,12 +357,12 @@ "integrity": "sha1-kTbgUD3MBqMBaQ8LsU/042TpSfA=", "dev": true, "requires": { - "d": "1", - "es5-ext": "~0.10.14", - "es6-iterator": "~2.0.1", - "es6-set": "~0.1.5", - "es6-symbol": "~3.1.1", - "event-emitter": "~0.3.5" + "d": "1.0.0", + "es5-ext": "0.10.37", + "es6-iterator": "2.0.3", + "es6-set": "0.1.5", + "es6-symbol": "3.1.1", + "event-emitter": "0.3.5" } }, "es6-set": { @@ -376,11 +371,11 @@ "integrity": "sha1-0rPsXU2ADO2BjbU40ol02wpzzLE=", "dev": true, "requires": { - "d": "1", - "es5-ext": "~0.10.14", - "es6-iterator": "~2.0.1", + "d": "1.0.0", + "es5-ext": "0.10.37", + "es6-iterator": "2.0.3", "es6-symbol": "3.1.1", - "event-emitter": "~0.3.5" + "event-emitter": "0.3.5" } }, "es6-symbol": { @@ -389,8 +384,8 @@ "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", "dev": true, "requires": { - "d": "1", - "es5-ext": "~0.10.14" + "d": "1.0.0", + "es5-ext": "0.10.37" } }, "es6-weak-map": { @@ -399,10 +394,10 @@ "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", "dev": true, "requires": { - "d": "1", - "es5-ext": "^0.10.14", - "es6-iterator": "^2.0.1", - "es6-symbol": "^3.1.1" + "d": "1.0.0", + "es5-ext": "0.10.37", + "es6-iterator": "2.0.3", + "es6-symbol": "3.1.1" } }, "escape-string-regexp": { @@ -417,10 +412,10 @@ "integrity": "sha1-4Bl16BJ4GhY6ba392AOY3GTIicM=", "dev": true, "requires": { - "es6-map": "^0.1.3", - "es6-weak-map": "^2.0.1", - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" + "es6-map": "0.1.5", + "es6-weak-map": "2.0.2", + "esrecurse": "4.2.0", + "estraverse": "4.2.0" } }, "eslint": { @@ -429,41 +424,41 @@ "integrity": "sha1-yPxiAcf0DdCJQbh8CFdnOGpnmsw=", "dev": true, "requires": { - "babel-code-frame": "^6.16.0", - "chalk": "^1.1.3", - "concat-stream": "^1.5.2", - "debug": "^2.1.1", - "doctrine": "^2.0.0", - "escope": "^3.6.0", - "espree": "^3.4.0", - "esquery": "^1.0.0", - "estraverse": "^4.2.0", - "esutils": "^2.0.2", - "file-entry-cache": "^2.0.0", - "glob": "^7.0.3", - "globals": "^9.14.0", - "ignore": "^3.2.0", - "imurmurhash": "^0.1.4", - "inquirer": "^0.12.0", - "is-my-json-valid": "^2.10.0", - "is-resolvable": "^1.0.0", - "js-yaml": "^3.5.1", - "json-stable-stringify": "^1.0.0", - "levn": "^0.3.0", - "lodash": "^4.0.0", - "mkdirp": "^0.5.0", - "natural-compare": "^1.4.0", - "optionator": "^0.8.2", - "path-is-inside": "^1.0.1", - "pluralize": "^1.2.1", - "progress": "^1.1.8", - "require-uncached": "^1.0.2", - "shelljs": "^0.7.5", - "strip-bom": "^3.0.0", - "strip-json-comments": "~2.0.1", - "table": "^3.7.8", - "text-table": "~0.2.0", - "user-home": "^2.0.0" + "babel-code-frame": "6.26.0", + "chalk": "1.1.3", + "concat-stream": "1.6.0", + "debug": "2.6.9", + "doctrine": "2.0.2", + "escope": "3.6.0", + "espree": "3.5.2", + "esquery": "1.0.0", + "estraverse": "4.2.0", + "esutils": "2.0.2", + "file-entry-cache": "2.0.0", + "glob": "7.1.2", + "globals": "9.18.0", + "ignore": "3.3.7", + "imurmurhash": "0.1.4", + "inquirer": "0.12.0", + "is-my-json-valid": "2.17.1", + "is-resolvable": "1.0.1", + "js-yaml": "3.10.0", + "json-stable-stringify": "1.0.1", + "levn": "0.3.0", + "lodash": "4.17.11", + "mkdirp": "0.5.1", + "natural-compare": "1.4.0", + "optionator": "0.8.2", + "path-is-inside": "1.0.2", + "pluralize": "1.2.1", + "progress": "1.1.8", + "require-uncached": "1.0.3", + "shelljs": "0.7.8", + "strip-bom": "3.0.0", + "strip-json-comments": "2.0.1", + "table": "3.8.3", + "text-table": "0.2.0", + "user-home": "2.0.0" }, "dependencies": { "debug": { @@ -483,7 +478,7 @@ "integrity": "sha512-/fhjt/VqzBA2SRsx7ErDtv6Ayf+XLw9LIOqmpBuHFCVwyJo2EtzGWMB9fYRFBoWWQLxmNmCpenNiH0RxyeS41w==", "dev": true, "requires": { - "eslint-restricted-globals": "^0.1.1" + "eslint-restricted-globals": "0.1.1" } }, "eslint-config-transit": { @@ -492,7 +487,7 @@ "integrity": "sha512-9rG76lB7lzUcKt8fe5C4NfQ7C9DsuLqBZpITOdp07y3dd+Vna4B/sVeXXAanfP6qYzoELUHwNyrVrT6pNR34kQ==", "dev": true, "requires": { - "eslint-config-airbnb-base": "^11.1.0" + "eslint-config-airbnb-base": "11.3.2" } }, "eslint-import-resolver-node": { @@ -501,8 +496,8 @@ "integrity": "sha512-yUtXS15gIcij68NmXmP9Ni77AQuCN0itXbCc/jWd8C6/yKZaSNXicpC8cgvjnxVdmfsosIXrjpzFq7GcDryb6A==", "dev": true, "requires": { - "debug": "^2.6.8", - "resolve": "^1.2.0" + "debug": "2.6.9", + "resolve": "1.5.0" }, "dependencies": { "debug": { @@ -522,8 +517,8 @@ "integrity": "sha512-jDI/X5l/6D1rRD/3T43q8Qgbls2nq5km5KSqiwlyUbGo5+04fXhMKdCPhjwbqAa6HXWaMxj8Q4hQDIh7IadJQw==", "dev": true, "requires": { - "debug": "^2.6.8", - "pkg-dir": "^1.0.0" + "debug": "2.6.9", + "pkg-dir": "1.0.0" }, "dependencies": { "debug": { @@ -543,16 +538,16 @@ "integrity": "sha512-Rf7dfKJxZ16QuTgVv1OYNxkZcsu/hULFnC+e+w0Gzi6jMC3guQoWQgxYxc54IDRinlb6/0v5z/PxxIKmVctN+g==", "dev": true, "requires": { - "builtin-modules": "^1.1.1", - "contains-path": "^0.1.0", - "debug": "^2.6.8", + "builtin-modules": "1.1.1", + "contains-path": "0.1.0", + "debug": "2.6.9", "doctrine": "1.5.0", - "eslint-import-resolver-node": "^0.3.1", - "eslint-module-utils": "^2.1.1", - "has": "^1.0.1", - "lodash.cond": "^4.3.0", - "minimatch": "^3.0.3", - "read-pkg-up": "^2.0.0" + "eslint-import-resolver-node": "0.3.1", + "eslint-module-utils": "2.1.1", + "has": "1.0.1", + "lodash.cond": "4.5.2", + "minimatch": "3.0.4", + "read-pkg-up": "2.0.0" }, "dependencies": { "debug": { @@ -570,8 +565,8 @@ "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", "dev": true, "requires": { - "esutils": "^2.0.2", - "isarray": "^1.0.0" + "esutils": "2.0.2", + "isarray": "1.0.0" } } } @@ -588,8 +583,8 @@ "integrity": "sha512-sadKeYwaR/aJ3stC2CdvgXu1T16TdYN+qwCpcWbMnGJ8s0zNWemzrvb2GbD4OhmJ/fwpJjudThAlLobGbWZbCQ==", "dev": true, "requires": { - "acorn": "^5.2.1", - "acorn-jsx": "^3.0.0" + "acorn": "5.3.0", + "acorn-jsx": "3.0.1" } }, "esprima": { @@ -604,7 +599,7 @@ "integrity": "sha1-z7qLV9f7qT8XKYqKAGoEzaE9gPo=", "dev": true, "requires": { - "estraverse": "^4.0.0" + "estraverse": "4.2.0" } }, "esrecurse": { @@ -613,8 +608,8 @@ "integrity": "sha1-+pVo2Y04I/mkHZHpAtyrnqblsWM=", "dev": true, "requires": { - "estraverse": "^4.1.0", - "object-assign": "^4.0.1" + "estraverse": "4.2.0", + "object-assign": "4.1.1" } }, "estraverse": { @@ -635,8 +630,8 @@ "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", "dev": true, "requires": { - "d": "1", - "es5-ext": "~0.10.14" + "d": "1.0.0", + "es5-ext": "0.10.37" } }, "exit-hook": { @@ -657,8 +652,8 @@ "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", "dev": true, "requires": { - "escape-string-regexp": "^1.0.5", - "object-assign": "^4.1.0" + "escape-string-regexp": "1.0.5", + "object-assign": "4.1.1" } }, "file-entry-cache": { @@ -667,8 +662,8 @@ "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", "dev": true, "requires": { - "flat-cache": "^1.2.1", - "object-assign": "^4.0.1" + "flat-cache": "1.3.0", + "object-assign": "4.1.1" } }, "find-up": { @@ -677,8 +672,8 @@ "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", "dev": true, "requires": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" + "path-exists": "2.1.0", + "pinkie-promise": "2.0.1" } }, "flat-cache": { @@ -687,10 +682,10 @@ "integrity": "sha1-0wMLMrOBVPTjt+nHCfSQ9++XxIE=", "dev": true, "requires": { - "circular-json": "^0.3.1", - "del": "^2.0.2", - "graceful-fs": "^4.1.2", - "write": "^0.2.1" + "circular-json": "0.3.3", + "del": "2.2.2", + "graceful-fs": "4.1.11", + "write": "0.2.1" } }, "fs-extra": { @@ -698,9 +693,9 @@ "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-5.0.0.tgz", "integrity": "sha512-66Pm4RYbjzdyeuqudYqhFiNBbCIuI9kgRqLPSHIlXHidW8NIQtVdkM1yeZ4lXwuhbTETv3EUGMNHAAw6hiundQ==", "requires": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" + "graceful-fs": "4.1.11", + "jsonfile": "4.0.0", + "universalify": "0.1.1" } }, "fs.realpath": { @@ -727,7 +722,7 @@ "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", "dev": true, "requires": { - "is-property": "^1.0.0" + "is-property": "1.0.2" } }, "glob": { @@ -736,12 +731,12 @@ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" } }, "globals": { @@ -756,12 +751,12 @@ "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", "dev": true, "requires": { - "array-union": "^1.0.1", - "arrify": "^1.0.0", - "glob": "^7.0.3", - "object-assign": "^4.0.1", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" + "array-union": "1.0.2", + "arrify": "1.0.1", + "glob": "7.1.2", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" } }, "graceful-fs": { @@ -781,7 +776,7 @@ "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=", "dev": true, "requires": { - "function-bind": "^1.0.2" + "function-bind": "1.1.1" } }, "has-ansi": { @@ -790,7 +785,7 @@ "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true, "requires": { - "ansi-regex": "^2.0.0" + "ansi-regex": "2.1.1" } }, "has-flag": { @@ -829,8 +824,8 @@ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { - "once": "^1.3.0", - "wrappy": "1" + "once": "1.4.0", + "wrappy": "1.0.2" } }, "inherits": { @@ -845,19 +840,19 @@ "integrity": "sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34=", "dev": true, "requires": { - "ansi-escapes": "^1.1.0", - "ansi-regex": "^2.0.0", - "chalk": "^1.0.0", - "cli-cursor": "^1.0.1", - "cli-width": "^2.0.0", - "figures": "^1.3.5", - "lodash": "^4.3.0", - "readline2": "^1.0.1", - "run-async": "^0.1.0", - "rx-lite": "^3.1.2", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.0", - "through": "^2.3.6" + "ansi-escapes": "1.4.0", + "ansi-regex": "2.1.1", + "chalk": "1.1.3", + "cli-cursor": "1.0.2", + "cli-width": "2.2.0", + "figures": "1.7.0", + "lodash": "4.17.11", + "readline2": "1.0.1", + "run-async": "0.1.0", + "rx-lite": "3.1.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "through": "2.3.8" } }, "interpret": { @@ -878,7 +873,7 @@ "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", "dev": true, "requires": { - "builtin-modules": "^1.0.0" + "builtin-modules": "1.1.1" } }, "is-fullwidth-code-point": { @@ -887,7 +882,7 @@ "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, "requires": { - "number-is-nan": "^1.0.0" + "number-is-nan": "1.0.1" } }, "is-my-json-valid": { @@ -896,10 +891,10 @@ "integrity": "sha512-Q2khNw+oBlWuaYvEEHtKSw/pCxD2L5Rc1C+UQme9X6JdRDh7m5D7HkozA0qa3DUkQ6VzCnEm8mVIQPyIRkI5sQ==", "dev": true, "requires": { - "generate-function": "^2.0.0", - "generate-object-property": "^1.1.0", - "jsonpointer": "^4.0.0", - "xtend": "^4.0.0" + "generate-function": "2.0.0", + "generate-object-property": "1.2.0", + "jsonpointer": "4.0.1", + "xtend": "4.0.1" } }, "is-path-cwd": { @@ -914,7 +909,7 @@ "integrity": "sha1-ZHdYK4IU1gI0YJRWcAO+ip6sBNw=", "dev": true, "requires": { - "is-path-inside": "^1.0.0" + "is-path-inside": "1.0.1" } }, "is-path-inside": { @@ -923,7 +918,7 @@ "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", "dev": true, "requires": { - "path-is-inside": "^1.0.1" + "path-is-inside": "1.0.2" } }, "is-property": { @@ -956,8 +951,8 @@ "integrity": "sha512-O2v52ffjLa9VeM43J4XocZE//WT9N0IiwDa3KSHH7Tu8CtH+1qM8SIZvnsTh6v+4yFy5KUY3BHUVwjpfAWsjIA==", "dev": true, "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" + "argparse": "1.0.9", + "esprima": "4.0.0" } }, "json-stable-stringify": { @@ -966,7 +961,7 @@ "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", "dev": true, "requires": { - "jsonify": "~0.0.0" + "jsonify": "0.0.0" } }, "jsonfile": { @@ -974,7 +969,7 @@ "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", "requires": { - "graceful-fs": "^4.1.6" + "graceful-fs": "4.1.11" } }, "jsonify": { @@ -995,8 +990,8 @@ "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", "dev": true, "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" + "prelude-ls": "1.1.2", + "type-check": "0.3.2" } }, "load-json-file": { @@ -1005,10 +1000,10 @@ "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", "dev": true, "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "strip-bom": "^3.0.0" + "graceful-fs": "4.1.11", + "parse-json": "2.2.0", + "pify": "2.3.0", + "strip-bom": "3.0.0" } }, "locate-path": { @@ -1017,8 +1012,8 @@ "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", "dev": true, "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" + "p-locate": "2.0.0", + "path-exists": "3.0.0" }, "dependencies": { "path-exists": { @@ -1046,7 +1041,7 @@ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { - "brace-expansion": "^1.1.7" + "brace-expansion": "1.1.8" } }, "minimist": { @@ -1089,7 +1084,7 @@ "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "has-flag": "3.0.0" } } } @@ -1117,10 +1112,10 @@ "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { - "hosted-git-info": "^2.1.4", - "is-builtin-module": "^1.0.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" + "hosted-git-info": "2.5.0", + "is-builtin-module": "1.0.0", + "semver": "5.4.1", + "validate-npm-package-license": "3.0.1" } }, "number-is-nan": { @@ -1141,7 +1136,7 @@ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { - "wrappy": "1" + "wrappy": "1.0.2" } }, "onetime": { @@ -1156,12 +1151,12 @@ "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", "dev": true, "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.4", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "wordwrap": "~1.0.0" + "deep-is": "0.1.3", + "fast-levenshtein": "2.0.6", + "levn": "0.3.0", + "prelude-ls": "1.1.2", + "type-check": "0.3.2", + "wordwrap": "1.0.0" } }, "os-homedir": { @@ -1182,16 +1177,21 @@ "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", "dev": true, "requires": { - "p-limit": "^1.1.0" + "p-limit": "1.1.0" } }, + "papaparse": { + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/papaparse/-/papaparse-4.6.3.tgz", + "integrity": "sha512-LRq7BrHC2kHPBYSD50aKuw/B/dGcg29omyJbKWY3KsYUZU69RKwaBHu13jGmCYBtOc4odsLCrFyk6imfyNubJQ==" + }, "parse-json": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", "dev": true, "requires": { - "error-ex": "^1.2.0" + "error-ex": "1.3.1" } }, "path-exists": { @@ -1200,7 +1200,7 @@ "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", "dev": true, "requires": { - "pinkie-promise": "^2.0.0" + "pinkie-promise": "2.0.1" } }, "path-is-absolute": { @@ -1227,7 +1227,7 @@ "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", "dev": true, "requires": { - "pify": "^2.0.0" + "pify": "2.3.0" } }, "pify": { @@ -1248,7 +1248,7 @@ "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", "dev": true, "requires": { - "pinkie": "^2.0.0" + "pinkie": "2.0.4" } }, "pkg-dir": { @@ -1257,7 +1257,7 @@ "integrity": "sha1-ektQio1bstYp1EcFb/TpyTFM89Q=", "dev": true, "requires": { - "find-up": "^1.0.0" + "find-up": "1.1.2" } }, "pluralize": { @@ -1290,9 +1290,9 @@ "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", "dev": true, "requires": { - "load-json-file": "^2.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^2.0.0" + "load-json-file": "2.0.0", + "normalize-package-data": "2.4.0", + "path-type": "2.0.0" } }, "read-pkg-up": { @@ -1301,8 +1301,8 @@ "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", "dev": true, "requires": { - "find-up": "^2.0.0", - "read-pkg": "^2.0.0" + "find-up": "2.1.0", + "read-pkg": "2.0.0" }, "dependencies": { "find-up": { @@ -1311,7 +1311,7 @@ "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", "dev": true, "requires": { - "locate-path": "^2.0.0" + "locate-path": "2.0.0" } } } @@ -1322,13 +1322,13 @@ "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", "dev": true, "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~1.0.6", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.0.3", - "util-deprecate": "~1.0.1" + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" } }, "readline2": { @@ -1337,8 +1337,8 @@ "integrity": "sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=", "dev": true, "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", "mute-stream": "0.0.5" } }, @@ -1348,7 +1348,7 @@ "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", "dev": true, "requires": { - "resolve": "^1.1.6" + "resolve": "1.5.0" } }, "require-uncached": { @@ -1357,8 +1357,8 @@ "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", "dev": true, "requires": { - "caller-path": "^0.1.0", - "resolve-from": "^1.0.0" + "caller-path": "0.1.0", + "resolve-from": "1.0.1" } }, "resolve": { @@ -1367,7 +1367,7 @@ "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { - "path-parse": "^1.0.5" + "path-parse": "1.0.5" } }, "resolve-from": { @@ -1382,8 +1382,8 @@ "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", "dev": true, "requires": { - "exit-hook": "^1.0.0", - "onetime": "^1.0.0" + "exit-hook": "1.1.1", + "onetime": "1.1.0" } }, "rimraf": { @@ -1392,7 +1392,7 @@ "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { - "glob": "^7.0.5" + "glob": "7.1.2" } }, "run-async": { @@ -1401,7 +1401,7 @@ "integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=", "dev": true, "requires": { - "once": "^1.3.0" + "once": "1.4.0" } }, "rx-lite": { @@ -1428,9 +1428,9 @@ "integrity": "sha1-3svPh0sNHl+3LhSxZKloMEjprLM=", "dev": true, "requires": { - "glob": "^7.0.0", - "interpret": "^1.0.0", - "rechoir": "^0.6.2" + "glob": "7.1.2", + "interpret": "1.1.0", + "rechoir": "0.6.2" } }, "slice-ansi": { @@ -1445,7 +1445,7 @@ "integrity": "sha1-SzBz2TP/UfORLwOsVRlJikFQ20A=", "dev": true, "requires": { - "spdx-license-ids": "^1.0.2" + "spdx-license-ids": "1.2.2" } }, "spdx-expression-parse": { @@ -1472,9 +1472,9 @@ "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" } }, "string_decoder": { @@ -1483,7 +1483,7 @@ "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", "dev": true, "requires": { - "safe-buffer": "~5.1.0" + "safe-buffer": "5.1.1" } }, "strip-ansi": { @@ -1492,7 +1492,7 @@ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { - "ansi-regex": "^2.0.0" + "ansi-regex": "2.1.1" } }, "strip-bom": { @@ -1519,12 +1519,12 @@ "integrity": "sha1-K7xULw/amGGnVdOUf+/Ys/UThV8=", "dev": true, "requires": { - "ajv": "^4.7.0", - "ajv-keywords": "^1.0.0", - "chalk": "^1.1.1", - "lodash": "^4.0.0", + "ajv": "4.11.8", + "ajv-keywords": "1.5.1", + "chalk": "1.1.3", + "lodash": "4.17.11", "slice-ansi": "0.0.4", - "string-width": "^2.0.0" + "string-width": "2.1.1" }, "dependencies": { "ansi-regex": { @@ -1545,8 +1545,8 @@ "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "dev": true, "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" } }, "strip-ansi": { @@ -1555,7 +1555,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "3.0.0" } } } @@ -1578,7 +1578,7 @@ "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", "dev": true, "requires": { - "prelude-ls": "~1.1.2" + "prelude-ls": "1.1.2" } }, "type-detect": { @@ -1604,7 +1604,7 @@ "integrity": "sha1-nHC/2Babwdy/SGBODwS4tJzenp8=", "dev": true, "requires": { - "os-homedir": "^1.0.0" + "os-homedir": "1.0.2" } }, "util-deprecate": { @@ -1619,8 +1619,8 @@ "integrity": "sha1-KAS6vnEq0zeUWaz74kdGqywwP7w=", "dev": true, "requires": { - "spdx-correct": "~1.0.0", - "spdx-expression-parse": "~1.0.0" + "spdx-correct": "1.0.2", + "spdx-expression-parse": "1.0.4" } }, "wordwrap": { @@ -1641,7 +1641,7 @@ "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", "dev": true, "requires": { - "mkdirp": "^0.5.1" + "mkdirp": "0.5.1" } }, "xtend": { diff --git a/tests/samples/1/pathways.txt b/tests/samples/1/pathways.txt new file mode 100644 index 0000000..def697b --- /dev/null +++ b/tests/samples/1/pathways.txt @@ -0,0 +1,3 @@ +pathway_id,from_stop_id,to_stop_id,pathway_mode,is_bidirectional,length,traversal_time,stair_count,max_slope,min_width,signposted_as,reversed_signposted_as +1,stop_0,stop_1,1,0,10,72,12,,,sign_posted_as,reversed_sign_posted_as +2,stop_2,stop_3,2,0,10,72,12,,,sign_posted_as,reversed_sign_posted_as diff --git a/tests/test_generic_table_functions.js b/tests/test_generic_table_functions.js index c5ef7f0..8e0c61e 100644 --- a/tests/test_generic_table_functions.js +++ b/tests/test_generic_table_functions.js @@ -16,7 +16,7 @@ describe('Tests on GTFS generic table functions', () => { const expectedTableNames = [ 'agency', 'calendar', 'calendar_dates', 'fare_attributes', 'fare_rules', 'frequencies', - 'routes', 'stop_times', 'stops', 'trips', 'shapes', 'transfers', 'feed_info', + 'routes', 'stop_times', 'stops', 'trips', 'shapes', 'transfers', 'pathways', 'feed_info', ]; expect(Array.from(gtfs.getTableNames())).to.deep.equal(expectedTableNames); diff --git a/tests/test_pathways.js b/tests/test_pathways.js new file mode 100644 index 0000000..27bd140 --- /dev/null +++ b/tests/test_pathways.js @@ -0,0 +1,103 @@ +'use strict'; + +const { expect } = require('chai'); +const { Gtfs } = require('../index'); + +describe('Tests on GTFS pathways', () => { + it('Tests on pathways functions', (done) => { + const path = `${__dirname}/samples/1`; + const gtfs = new Gtfs(path); + expect(sortedKeys(gtfs.getIndexedPathways())).to.deep.equal(['1', '2']); + + const pathway1 = gtfs.getPathwayWithPathwayId('1'); + const pathway2 = gtfs.getPathwayWithPathwayId('2'); + expect(pathway1.pathway_mode).to.equal('1'); + expect(pathway1.is_bidirectional).to.equal('0'); + + gtfs.addPathway({ + pathway_id: '3', + from_stop_id: 'stop_4', + to_stop_id: 'stop_5', + pathway_mode: '1', + is_bidirectional: '0', + length: '100', + traversal_time: '60', + stair_count: '12', + max_slope: '', + min_width: '', + signposted_as: 'signposted_as', + reversed_signposted_as: 'reversed_signposted_as', + }); + expect(sortedKeys(gtfs.getIndexedPathways())).to.deep.equal(['1', '2', '3']); + + gtfs.addPathways([ + { + pathway_id: '4', + from_stop_id: 'stop_4', + to_stop_id: 'stop_6', + pathway_mode: '1', + is_bidirectional: '0', + length: '100', + traversal_time: '60', + stair_count: '12', + max_slope: '', + min_width: '', + signposted_as: 'signposted_as', + reversed_signposted_as: 'reversed_signposted_as', + }, + { + pathway_id: '5', + from_stop_id: 'stop_6', + to_stop_id: 'stop_7', + pathway_mode: '1', + is_bidirectional: '0', + length: '100', + traversal_time: '60', + stair_count: '12', + max_slope: '', + min_width: '', + signposted_as: 'signposted_as', + reversed_signposted_as: 'reversed_signposted_as', + }, + ]); + expect(sortedKeys(gtfs.getIndexedPathways())).to.deep.equal(['1', '2', '3', '4', '5']); + + gtfs.removePathway(gtfs.getPathwayWithPathwayId('1')); + expect(sortedKeys(gtfs.getIndexedPathways())).to.deep.equal(['2', '3', '4', '5']); + + gtfs.removePathways([ + gtfs.getPathwayWithPathwayId('2'), + gtfs.getPathwayWithPathwayId('3'), + ]); + + expect(sortedKeys(gtfs.getIndexedPathways())).to.deep.equal(['4', '5']); + + gtfs.setIndexedPathways(new Map([['1', pathway1], ['2', pathway2]])); + + expect(sortedKeys(gtfs.getIndexedPathways())).to.deep.equal(['1', '2']); + + const pathwayModes = []; + gtfs.forEachPathway((pathway) => { + pathwayModes.push(pathway.pathway_mode); + }); + expect(pathwayModes.sort()).to.deep.equal(['1', '2']); + + done(); + }); + + it('Tests on gtfs.resetTransfers()', (done) => { + const gtfs = new Gtfs(`${__dirname}/samples/1`); + + expect(gtfs.getIndexedPathways().size).to.equal(2); + + gtfs.resetPathways(); + + expect(gtfs.getIndexedPathways().size).to.equal(0); + + done(); + }); +}); + +function sortedKeys(map) { + return Array.from(map.keys()).sort(); +} From 0e975b07a76368398453692050e8310e45b3ec0b Mon Sep 17 00:00:00 2001 From: rahls7 Date: Tue, 19 Nov 2019 11:01:03 -0500 Subject: [PATCH 5/5] Fix: update jsdoc --- gtfs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtfs.js b/gtfs.js index 67b4dc9..d1a37be 100644 --- a/gtfs.js +++ b/gtfs.js @@ -1651,7 +1651,7 @@ class Gtfs { getIndexedPathways() { return getIndexedTable(this, 'pathways'); } /** - * Get a pathway using its indexes: the fromStopId and the toStopId. + * Get a pathway using its index: pathwayId. * * @param {string} pathwayId First index of the pathway * @return {Object} Pathway object