init commit

This commit is contained in:
Nicholas Orlowsky 2025-07-06 20:49:07 -04:00
parent d4b364716f
commit 4466021f07
No known key found for this signature in database
GPG key ID: A9F3BA4C0AA7A70B
18 changed files with 4734 additions and 2 deletions

1
libseptastic/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
target/

1583
libseptastic/Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

7
libseptastic/Cargo.toml Normal file
View file

@ -0,0 +1,7 @@
[package]
name = "libseptastic"
version = "0.1.0"
edition = "2024"
[dependencies]
sqlx = "0.8.6"

5
libseptastic/src/lib.rs Normal file
View file

@ -0,0 +1,5 @@
pub mod route;
pub mod stop;
pub mod route_stop;
pub mod stop_schedule;
pub mod schedule_day;

41
libseptastic/src/route.rs Normal file
View file

@ -0,0 +1,41 @@
#[derive(sqlx::Type, PartialEq, Debug, Clone)]
#[sqlx(type_name = "septa_route_type", rename_all = "snake_case")]
pub enum RouteType {
Trolley,
SubwayElevated,
RegionalRail,
Bus,
TracklessTrolley
}
#[derive(sqlx::Type, PartialEq, Debug, Clone)]
#[sqlx(type_name = "septa_direction_type", rename_all = "snake_case")]
pub enum CardinalDirection {
Northbound,
Southbound,
Eastbound,
Westbound // (and down)
}
#[derive(Debug, Clone)]
pub struct Directional {
pub direction: CardinalDirection,
pub direction_destination: String
}
#[derive(Debug, Clone)]
pub struct RouteDirectional {
pub primary: Directional, // 0
pub secondary: Directional, // 1
}
#[derive(Debug, Clone)]
pub struct Route {
pub name: String,
pub short_name: String,
pub color_hex: String,
pub route_type: RouteType,
pub id: String,
pub directional: RouteDirectional
}

View file

@ -0,0 +1,9 @@
use super::route::CardinalDirection;
#[derive(Debug, Clone)]
pub struct RouteStop {
pub route_id: String,
pub stop_id: i64,
pub direction: CardinalDirection,
pub stop_sequence: i64
}

View file

@ -0,0 +1,5 @@
#[derive(Debug, Clone)]
pub struct ScheduleDay {
pub date: String,
pub service_id: String
}

16
libseptastic/src/stop.rs Normal file
View file

@ -0,0 +1,16 @@
#[derive(sqlx::Type, PartialEq, Debug, Clone)]
#[sqlx(type_name = "septa_stop_type", rename_all = "snake_case")]
pub enum StopType {
FarSide,
MiddleBlockNearSide,
Normal
}
#[derive(Debug, Clone)]
pub struct Stop {
pub id: i64,
pub name: String,
pub lat: f64,
pub lng: f64,
pub stop_type: StopType
}

View file

@ -0,0 +1,12 @@
use super::route::CardinalDirection;
#[derive(Debug, Clone)]
pub struct StopSchedule {
pub route_id: String,
pub trip_id: String,
pub service_id: String,
pub direction: CardinalDirection,
pub arrival_time: i64,
pub stop_id: i64,
pub stop_sequence: i64
}