GTFS Schedule¶
The GTFS Schedule module provides an implementation of the General Transit Feed Specification (GTFS) Schedule for Kotlin Multiplatform.
GTFS Schedule is a standardized data format for public transit schedules and associated geographic information. It consists of a ZIP archive containing CSV files that describe transit routes, stops, trips, and schedules.
Features¶
- CSV encoding and decoding with kotlin-dsv
- Strong type safety, with appropriate standard library or kotlinx-datetime types
- Kotlin Multiplatform support (JVM, Native, JS, WASM)
Installation¶
Add the dependency to your build.gradle.kts:
dependencies {
implementation("dev.sargunv.mobility-data:gtfs-schedule:0.5.0")
}
Example¶
SystemFileSystem.source(Path("path/to/gtfs/agency.txt")).buffered().use { source -> // (1)!
val agencies = GtfsCsv.decodeFromSource<Agency>(source) // (2)!
agencies.forEach { agency -> // (3)!
println("Agency: ${agency.agencyName} (${agency.agencyId})")
}
}
- Open a GTFS CSV file (typically extracted from a ZIP archive).
- Use the
GtfsCsvformat which is preconfigured for GTFS .txt files. - Decode the CSV file into a sequence of strongly-typed entities and process them as needed.
API Reference¶
For detailed API documentation, see the API Reference.