Skip to content

Commit

Permalink
Merge pull request #21 from TransitApp/feat/add_pathways
Browse files Browse the repository at this point in the history
Feat/add pathways
  • Loading branch information
rahls7 committed Nov 21, 2019
2 parents c8703b4 + a837451 commit 93cda8b
Show file tree
Hide file tree
Showing 6 changed files with 420 additions and 224 deletions.
68 changes: 68 additions & 0 deletions gtfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.<Object>} 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.<string, Map.<string, Object>>} Indexed transfers.
*/
getIndexedPathways() { return getIndexedTable(this, 'pathways'); }

/**
* Get a pathway using its index: pathwayId.
*
* @param {string} pathwayId First index of the pathway
* @return {Object} Pathway object
*/
getPathwayWithPathwayId(pathwayId) {
return getters.getItemWithIndex(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.<Object>} 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.<string, Map.<string, Object>>} indexedPathways Map of pathways properly indexed (see schema.js).
*/
setIndexedPathways(indexedPathways) { setTable(this, 'pathways', indexedPathways); }


/* feed_info.txt */

Expand Down
19 changes: 17 additions & 2 deletions helpers/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const keysByTableName = {
'parent_station',
'stop_timezone',
'wheelchair_boarding',
'tts_stop_name'
'tts_stop_name',
],
routes: [
'route_id',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -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: { indexKey: 'pathway_id' },
feed_info: { singleton: true },
};

Expand Down
Loading

0 comments on commit 93cda8b

Please sign in to comment.