ontrack

Crates.ioontrack
lib.rsontrack
version0.0.6
created_at2025-11-25 23:53:59.074518+00
updated_at2025-12-21 14:23:51.269081+00
descriptionHigh-performance Rust library for routing, searching, and querying GTFS transit data with minimal runtime allocations.
homepage
repositoryhttps://github.com/VincentBrodin/ontrack
max_upload_size
id1950669
size258,246
Vincent Brodin (vincbro)

documentation

README

ontrack

Crates.io Documentation License

On Track is a high-performance Rust library designed to make transit data easy to work with. It handles the heavy lifting of loading, searching, and routing through complex GTFS transit schedules so you can focus on building your application.

[!NOTE] This project is early in development, if you like the idea and want to help improve it, please open an issue.

Key Features

  • Zero-Config Ingestion: Parses standard GTFS zip files out of the box, handling schema details automatically.
  • Graph-Based Routing: Delivers accurate pathfinding that respects transfer rules, dwell times, and physical access points.
  • Self-Contained Search: Features a built-in, multi-threaded fuzzy search algorithm, removing dependencies on external engines.
  • Geospatial Lookup: fast grid-based lookups associate user coordinates with the nearest stops and stations.
  • Optimized Memory Layout: A highly optimized Rust architecture ensures minimal RAM usage, ideal for containerized or edge environments.

Installation

Add On Track to your Cargo.toml:

cargo add ontrack

Quick Start

use ontrack::gtfs::{Gtfs, Config};
use ontrack::repository::Repository;
use ontrack::router::{Router, graph::Location};
use ontrack::shared::time::Time;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let gtfs = Gtfs::new(Config::default()).from_zip("transit_data.zip")?;
    let repo = Repository::new().with_gtfs(gtfs)?;

    let from = Location::Stop("STOP_ID_1".into());
    let to = Location::Coordinate(ontrack::shared::geo::Coordinate { latitude: 59.3, longitude: 18.0 });
    let departure = Time::from_seconds(36000); // 10:00 AM

    let itinerary = Router::new(repo, from, to, departure)?.run()?;

    println!("Found a route with {} legs!", itinerary.legs.len());
    Ok(())
} 

Core Concepts

  • Repository: Your central hub for transit data. It holds all the stops, routes, and schedules in a format optimized for speed.
  • Router: The logic engine that finds the best path. It understands how to connect different bus or train lines with walking paths.
  • Shared Utilities: Built-in tools for handling geographic distances and transit-specific time calculations.

Roadmap

  • Production-ready web server crate with docker image
  • Multi-threaded routing (Switching to RAPTOR)
  • Real-time data updates (GTFS-RT)
  • Advanced date and holiday filtering

Refrences

License

This project is licensed under the MIT License.

Commit count: 0

cargo fmt