Skip to content

Commit

Permalink
WIP: add pathways
Browse files Browse the repository at this point in the history
  • Loading branch information
rahls7 committed Oct 29, 2019
1 parent 6e76221 commit 151a982
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 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 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.<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
15 changes: 15 additions & 0 deletions helpers/schema.js
Original file line number Diff line number Diff line change
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: { firstIndexKey: 'pathway_id'},
feed_info: { singleton: true },
};

Expand Down

0 comments on commit 151a982

Please sign in to comment.