-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compression algorithm v1 for stop times
- Loading branch information
Showing
18 changed files
with
325 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,4 +59,5 @@ Session.vim | |
rustc-ice*.txt | ||
rustc-ice-* | ||
|
||
.env | ||
.env | ||
testing-gtfs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
migrations/2024-04-06-053500_timetable-compression-v1/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
-- This file should undo anything in `up.sql` | ||
CREATE TABLE gtfs.stoptimes ( | ||
onestop_feed_id text NOT NULL, | ||
attempt_id text NOT NULL, | ||
trip_id text NOT NULL, | ||
stop_sequence int NOT NULL, | ||
arrival_time OID, | ||
departure_time OID, | ||
stop_id text NOT NULL, | ||
stop_headsign text, | ||
stop_headsign_translations jsonb, | ||
pickup_type smallint NOT NULL, | ||
drop_off_type smallint NOT NULL, | ||
shape_dist_traveled float4, | ||
-- true is 1, false is 0 | ||
timepoint bool NOT NULL, | ||
continuous_pickup smallint NOT NULL, | ||
continuous_drop_off smallint NOT NULL, | ||
-- point GEOMETRY(POINT, 4326), | ||
route_id text NOT NULL, | ||
chateau text NOT NULL, | ||
PRIMARY KEY (onestop_feed_id, attempt_id, trip_id, stop_sequence) | ||
); | ||
|
||
CREATE INDEX stoptimes_chateau_idx ON gtfs.stoptimes (chateau); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- Your SQL goes here | ||
DROP TABLE IF EXISTS gtfs.stoptimes CASCADE; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[toolchain] | ||
channel = "nightly" | ||
channel = "stable" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
use gtfs_structures::BikesAllowedType; | ||
use gtfs_structures::ContinuousPickupDropOff; | ||
use gtfs_structures::LocationType; | ||
use gtfs_structures::RouteType; | ||
use gtfs_structures::TimepointType; | ||
|
||
pub fn location_type_conversion(input: &LocationType) -> i16 { | ||
match input { | ||
LocationType::StopPoint => 0, | ||
LocationType::StopArea => 1, | ||
LocationType::StationEntrance => 2, | ||
LocationType::GenericNode => 3, | ||
LocationType::BoardingArea => 4, | ||
LocationType::Unknown(i) => *i, | ||
} | ||
} | ||
|
||
pub fn route_type_to_int(input: &RouteType) -> i16 { | ||
match input { | ||
RouteType::Tramway => 0, | ||
RouteType::Subway => 1, | ||
RouteType::Rail => 2, | ||
RouteType::Bus => 3, | ||
RouteType::Ferry => 4, | ||
RouteType::CableCar => 5, | ||
RouteType::Gondola => 6, | ||
RouteType::Funicular => 7, | ||
RouteType::Coach => 200, | ||
RouteType::Air => 1100, | ||
RouteType::Taxi => 1500, | ||
RouteType::Other(i) => *i, | ||
} | ||
} | ||
|
||
pub fn availability_to_int(input: >fs_structures::Availability) -> i16 { | ||
match input { | ||
gtfs_structures::Availability::Available => 1, | ||
gtfs_structures::Availability::NotAvailable => 2, | ||
gtfs_structures::Availability::Unknown(unknown) => *unknown, | ||
gtfs_structures::Availability::InformationNotAvailable => 0, | ||
} | ||
} | ||
|
||
pub fn timepoint_to_bool(timepoint: &TimepointType) -> bool { | ||
match timepoint { | ||
TimepointType::Exact => true, | ||
TimepointType::Approximate => false, | ||
} | ||
} | ||
|
||
pub fn pickup_dropoff_to_i16(x: >fs_structures::PickupDropOffType) -> i16 { | ||
match x { | ||
gtfs_structures::PickupDropOffType::Regular => 0, | ||
gtfs_structures::PickupDropOffType::NotAvailable => 1, | ||
gtfs_structures::PickupDropOffType::ArrangeByPhone => 2, | ||
gtfs_structures::PickupDropOffType::CoordinateWithDriver => 3, | ||
gtfs_structures::PickupDropOffType::Unknown(x) => *x, | ||
} | ||
} | ||
|
||
pub fn continuous_pickup_drop_off_to_i16(x: &ContinuousPickupDropOff) -> i16 { | ||
match x { | ||
ContinuousPickupDropOff::Continuous => 0, | ||
ContinuousPickupDropOff::NotAvailable => 1, | ||
ContinuousPickupDropOff::ArrangeByPhone => 2, | ||
ContinuousPickupDropOff::CoordinateWithDriver => 3, | ||
ContinuousPickupDropOff::Unknown(x) => *x, | ||
} | ||
} | ||
|
||
pub fn bikes_allowed_to_int(bikes_allowed: &BikesAllowedType) -> i16 { | ||
match bikes_allowed { | ||
BikesAllowedType::NoBikeInfo => 0, | ||
BikesAllowedType::AtLeastOneBike => 1, | ||
BikesAllowedType::NoBikesAllowed => 2, | ||
BikesAllowedType::Unknown(unknown) => *unknown, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# GTFS compression algorithm | ||
|
||
The goal is to reduce the current 197 GB of Stop times into a series of transfer patterns and trip patterns. |
Oops, something went wrong.