@tmlmobilidade/types
Version:
71 lines (70 loc) • 2.81 kB
TypeScript
import { type GTFS_Binary, type GTFS_Ternary } from './common.js';
/**
* Represents a trip in the GTFS (General Transit Feed Specification) format.
* A trip is a sequence of one or more stops that a vehicle makes during its operation.
* Each trip is associated with a specific route and service schedule.
* The trip can have various attributes such as headsign, direction, and accessibility options.
*/
export interface GTFS_Trip {
bikes_allowed?: GTFS_Ternary;
block_id?: string;
direction_id: GTFS_Binary;
route_id: string;
service_id: string;
shape_id: string;
trip_headsign?: string;
trip_id: string;
trip_short_name?: string;
wheelchair_accessible: GTFS_Ternary;
}
/**
* Represents a raw trip in the GTFS format.
* This interface is used to parse raw data from GTFS files, where fields may be optional
* or represented as strings. It is typically used for data ingestion before validation
* and transformation into the `GTFS_Trip` format.
*/
export interface GTFS_Trip_Raw {
bikes_allowed?: string;
block_id?: string;
direction_id?: string;
pattern_id?: string;
route_id?: string;
service_id?: string;
shape_id?: string;
trip_headsign?: string;
trip_id?: string;
trip_short_name?: string;
wheelchair_accessible?: string;
}
/**
* Validates and transforms raw GTFS Trip data into a structured GTFS_Trip object.
* This function checks the types of fields, converts boolean strings to boolean values,
* and ensures that required fields are present.
* @param rawData The raw trip data to validate and transform.
* @returns A validated GTFS_Trip object.
*/
export declare function validateGtfsTrip(rawData: GTFS_Trip_Raw): GTFS_Trip;
/**
* Extended version of the GTFS_Trip interface that
* should be used for working with the GTFS-TML standard.
*/
export interface GTFS_Trip_Extended extends GTFS_Trip {
pattern_id: string;
}
/**
* Represents a raw trip in the GTFS-TML format.
* This interface is used to parse raw data from GTFS-TML files, where fields may be optional
* or represented as strings. It is typically used for data ingestion before validation
* and transformation into the `GTFS_Trip_Extended` format.
*/
export interface GTFS_Trip_Extended_Raw extends GTFS_Trip_Raw {
pattern_id?: string;
}
/**
* Validates and transforms raw GTFS-TML trip data into a structured GTFS_Trip_Extended object.
* This function checks the types of fields, converts boolean strings to boolean values,
* and ensures that required fields are present, including the pattern_id.
* @param rawData he raw trip data to validate and transform.
* @returns A validated GTFS_Trip_Extended object.
*/
export declare function validateGtfsTripExtended(rawData: GTFS_Trip_Extended_Raw): GTFS_Trip_Extended;