gis-tools-ts
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
92 lines • 2.79 kB
JavaScript
import { parseCSVAsRecord } from '../../';
/**
* # Trip Information
*
* ## Details
* **Required** - Trips for each route. A trip is a sequence of two or more stops that occur during
* a specific time period.
*/
export class GTFSTrip {
/**
* **Required**
* Identifies which route this trip belongs to (`routes.route_id`).
*/
routeId;
/**
* **Required**
* Identifies a set of dates when service is available (`calendar.service_id` or `calendar_dates.service_id`).
*/
serviceId;
/**
* **Required**
* Unique identifier for a trip (`trip_id`).
*/
id;
/**
* **Optional**
* Destination sign text that identifies the trip’s destination to riders.
*/
headsign;
/**
* **Optional**
* Public-facing text used to identify the trip (e.g., train numbers).
*/
shortName;
/**
* Updated to use an enum for direction.
* 0 = Outbound, 1 = Inbound.
*/
directionId;
/**
* **Optional**
* Identifies the block this trip belongs to. Sequential trips with the same block_id typically use the same vehicle.
*/
blockId;
/**
* **Conditionally Required**
* References a geospatial shape describing the vehicle's travel path (`shapes.shape_id`).
* Required if the trip uses continuous pickup or drop-off rules; otherwise optional.
*/
shapeId;
/**
* Updated to use an enum for wheelchair accessibility.
* 0 = NoInfo, 1 = Accessible, 2 = NotAccessible.
*/
wheelchairAccessible;
/**
* Updated to use an enum for bikes allowed.
* 0 = NoInfo, 1 = Allowed, 2 = NotAllowed.
*/
bikesAllowed;
/** @param data - the parsed GTFS CSV data */
constructor(data) {
this.routeId = data.route_id;
this.serviceId = data.service_id;
this.id = data.trip_id;
this.headsign = data.trip_headsign;
this.shortName = data.trip_short_name;
this.directionId =
data.direction_id !== undefined
? parseInt(data.direction_id, 10)
: undefined;
this.blockId = data.block_id;
this.shapeId = data.shape_id;
this.wheelchairAccessible =
data.wheelchair_accessible !== undefined
? parseInt(data.wheelchair_accessible, 10)
: undefined;
this.bikesAllowed =
data.bikes_allowed !== undefined
? parseInt(data.bikes_allowed, 10)
: undefined;
}
}
/**
* @param input - the input string to parse from
* @returns - an array of Trips
*/
export function parseGTFSTrips(input) {
const data = parseCSVAsRecord(input);
return data.map((d) => new GTFSTrip(d));
}
//# sourceMappingURL=trips.js.map