UNPKG

s2-tools

Version:

A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.

49 lines 1.35 kB
import { parseCSVAsRecord } from '../../'; /** * # Levels * * **Conditionally Required** * Describes levels in a station, useful with `pathways.txt`. * Required if `pathways` include elevators (`pathway_mode=5`), otherwise optional. */ export class GTFSLevel { /** * **Required** * Identifies a level in a station (`level_id`). */ id; /** * **Required** * Numeric index indicating this level's relative position: * - 0 for ground level * - Positive above ground * - Negative below ground */ levelIndex; /** * **Optional** * Name of the level as displayed to the rider (e.g., "Mezzanine", "Platform"). */ levelName; /** @param data - the parsed GTFS CSV data */ constructor(data) { this.id = data.level_id; // Convert to float or default to 0 this.levelIndex = data.level_index !== undefined ? parseFloat(data.level_index) : 0; this.levelName = data.level_name; } } /** * @param input - the input string to parse from * @returns - an array of Level */ export function parseGTFSLevels(input) { const data = parseCSVAsRecord(input); const res = {}; for (const d of data) { const level = new GTFSLevel(d); res[level.id] = level; } return res; } //# sourceMappingURL=levels.js.map