gis-tools-ts
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
52 lines • 1.32 kB
JavaScript
import { parseCSVAsRecord } from '../../';
/**
* # 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)
: 0 /* 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