s2-tools
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
69 lines • 1.98 kB
JavaScript
import { parseCSVAsRecord } from '../../';
/**
*
* Describes the type of fare media used.
* 0 - None
* 1 - Physical paper ticket
* 2 - Physical transit card
* 3 - cEMV (contactless)
* 4 - Mobile app
*/
export var GTFSFareMediaType;
(function (GTFSFareMediaType) {
GTFSFareMediaType[GTFSFareMediaType["None"] = 0] = "None";
GTFSFareMediaType[GTFSFareMediaType["PhysicalPaperTicket"] = 1] = "PhysicalPaperTicket";
GTFSFareMediaType[GTFSFareMediaType["PhysicalTransitCard"] = 2] = "PhysicalTransitCard";
GTFSFareMediaType[GTFSFareMediaType["CEMV"] = 3] = "CEMV";
GTFSFareMediaType[GTFSFareMediaType["MobileApp"] = 4] = "MobileApp";
})(GTFSFareMediaType || (GTFSFareMediaType = {}));
/**
* # Fare Media
*
* **Optional**
* Describes physical or virtual holders used for the representation and validation of a fare product.
*/
export class GTFSFareMedia {
/**
* **Required**
* Identifies a fare media (`fare_media_id`).
*/
id;
/**
* **Optional**
* Rider-facing name for this fare media.
*/
name;
/**
* **Required**
* Type of fare media. One of:
* - 0 = None
* - 1 = Physical paper ticket
* - 2 = Physical transit card
* - 3 = cEMV (contactless)
* - 4 = Mobile app
*/
type;
/** @param data - the parsed GTFS CSV data */
constructor(data) {
this.id = data.fare_media_id;
this.name = data.fare_media_name;
this.type =
data.fare_media_type !== undefined
? parseInt(data.fare_media_type, 10)
: GTFSFareMediaType.None;
}
}
/**
* @param input - the input string to parse from
* @returns - an array of GTFSFareMedias
*/
export function parseGTFSFareMedias(input) {
const data = parseCSVAsRecord(input);
const res = {};
for (const d of data) {
const fm = new GTFSFareMedia(d);
res[fm.id] = fm;
}
return res;
}
//# sourceMappingURL=fareMedia.js.map