@tmlmobilidade/types
Version:
133 lines (132 loc) • 4.94 kB
TypeScript
import { type GTFS_Binary, GTFS_HasField, type GTFS_Ternary } from './common.js';
/**
* Represents a GTFS (General Transit Feed Specification) Location Type.
* This type is used to categorize the location based on its function in the transit system.
* Each location type corresponds to a specific role, such as a stop, station, or boarding area.
* The values are defined according to the GTFS specification.
*/
export type GTFS_LocationType = 0 | 1 | 2 | 3 | 4;
/**
* Validates and transforms a value into a GTFS Location Type.
* It accepts numeric or string representations of location types.
* @param value The value to validate and transform.
* @returns A GTFS Location Type value (0-4).
* @throws Error if the value is not a valid GTFS Location type representation.
*/
export declare function validateGtfsLocationType(value?: number | string): GTFS_LocationType;
/**
* Represents a stop in the GTFS (General Transit Feed Specification) format.
* A stop is a group of trips that operate on a specific path or service,
* typically identified by a unique stop ID. Each stop can have various attributes
* such as agency ID, stop color, long name, short name, and type of service.
*/
export interface GTFS_Stop {
level_id?: string;
location_type: GTFS_LocationType;
parent_station?: string;
platform_code?: string;
stop_code: string;
stop_desc?: string;
stop_id: string;
stop_lat: number;
stop_lon: number;
stop_name: string;
stop_timezone?: string;
stop_url?: string;
wheelchair_boarding?: GTFS_Ternary;
zone_id?: string;
}
/**
* Represents a raw stop 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_Stop` format.
*/
export interface GTFS_Stop_Raw {
level_id?: string;
location_type?: string;
parent_station?: string;
platform_code?: string;
stop_code?: string;
stop_desc?: string;
stop_id?: string;
stop_lat?: string;
stop_lon?: string;
stop_name?: string;
stop_timezone?: string;
stop_url?: string;
wheelchair_boarding?: string;
zone_id?: string;
}
/**
* Validates and transforms a raw GTFS stop into the GTFS_Stop format.
* 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_Stop object.
*/
export declare function validateGtfsStop(rawData: GTFS_Stop_Raw): GTFS_Stop;
/**
* Extended version of the GTFS_Stop interface that
* should be used for working with the GTFS-TML standard.
*/
export interface GTFS_Stop_Extended extends GTFS_Stop {
district_id?: string;
district_name?: string;
has_bench?: GTFS_HasField;
has_network_map?: GTFS_HasField;
has_pip_real_time?: GTFS_HasField;
has_schedules?: GTFS_HasField;
has_shelter?: GTFS_HasField;
has_stop_sign?: GTFS_HasField;
has_tariffs_information?: GTFS_HasField;
locality_id?: string;
locality_name?: string;
municipality_id?: string;
municipality_name?: string;
parish_id?: string;
parish_name?: string;
public_visible?: GTFS_Binary;
region_id?: string;
shelter_code?: string;
shelter_maintainer?: string;
stop_short_name?: string;
tts_stop_name?: string;
}
/**
* Represents a raw stop 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_Stop_Extended` format.
*/
export interface GTFS_Stop_Extended_Raw extends GTFS_Stop_Raw {
district_id?: string;
district_name?: string;
has_bench?: string;
has_network_map?: string;
has_pip_real_time?: string;
has_schedules?: string;
has_shelter?: string;
has_stop_sign?: string;
has_tariffs_information?: string;
locality_id?: string;
locality_name?: string;
municipality_id?: string;
municipality_name?: string;
parish_id?: string;
parish_name?: string;
public_visible?: string;
region_id?: string;
shelter_code?: string;
shelter_maintainer?: string;
stop_short_name?: string;
tts_stop_name?: string;
}
/**
* Validates and transforms raw GTFS-TML stop data into a structured GTFS_Stop_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 stop data to validate and transform.
* @returns A validated GTFS_Stop_Extended object.
*/
export declare function validateGtfsStopExtended(rawData: GTFS_Stop_Extended_Raw): GTFS_Stop_Extended;