gtfs
GTFS - A type-safe GTFS library for Gleam
This library provides complete support for parsing and working with GTFS (General Transit Feed Specification) data, including:
- GTFS Static: Schedule data (routes, stops, trips, times, etc.)
- GTFS Realtime: Live updates (trip updates, vehicle positions, alerts)
Quick Start - Static Feed
import gtfs/static/feed
pub fn main() {
// Load a GTFS feed from a directory
let assert Ok(feed) = feed.load_from_directory("./gtfs_data")
// Access the data
let routes = feed.routes
let stops = feed.stops
}
Quick Start - Realtime Feed
import gtfs/realtime/feed as rt_feed
pub fn handle_realtime(data: BitArray) {
let assert Ok(feed) = rt_feed.decode(data)
// Get all trip updates
let trip_updates = rt_feed.get_trip_updates(feed)
// Get all vehicle positions
let vehicles = rt_feed.get_vehicle_positions(feed)
// Get all alerts
let alerts = rt_feed.get_alerts(feed)
}
Module Structure
Static (Schedule Data)
gtfs/static/feed- Load and query GTFS Static feedsgtfs/static/types- All GTFS Static type definitionsgtfs/static/validation- Feed validation utilities
Realtime (Live Updates)
gtfs/realtime/feed- Decode and query GTFS Realtime feedsgtfs/realtime/types- All GTFS Realtime type definitionsgtfs/realtime/decoder- Protocol Buffer decoder
Common
gtfs/common/types- Shared types (Date, Time, Coordinate, etc.)gtfs/common/time- Time parsing and manipulation utilitiesgtfs/common/geo- Geographic utilities (distance, polylines, etc.)
Types
pub type Agency =
types.Agency
pub type Alert =
types.Alert
pub type Calendar =
types.Calendar
pub type CalendarDate =
types.CalendarDate
pub type Color =
types.Color
pub type Coordinate =
types.Coordinate
pub type Date =
types.Date
pub type ExceptionType =
types.ExceptionType
pub type FeedEntity =
types.FeedEntity
pub type FeedHeader =
types.FeedHeader
pub type FeedMessage =
types.FeedMessage
pub type LanguageCode =
types.LanguageCode
pub type LocationType =
types.LocationType
pub type Position =
types.Position
pub type Route =
types.Route
pub type RouteType =
types.RouteType
pub type ShapePoint =
types.ShapePoint
pub type Stop =
types.Stop
pub type StopTime =
types.StopTime
pub type Time =
types.Time
pub type Timezone =
types.Timezone
pub type Trip =
types.Trip
pub type TripDescriptor =
types.TripDescriptor
pub type TripUpdate =
types.TripUpdate
pub type VehicleDescriptor =
types.VehicleDescriptor
pub type VehiclePosition =
types.VehiclePosition