Skip to content

Commit

Permalink
Remove point column from stop_times table, use enumeration as sequenc…
Browse files Browse the repository at this point in the history
…e id
  • Loading branch information
kylerchin committed Mar 31, 2024
1 parent 1589651 commit d0bf545
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
2 changes: 1 addition & 1 deletion migrations/2024-03-26-004608_init/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ CREATE TABLE gtfs.stoptimes (
timepoint bool NOT NULL,
continuous_pickup smallint NOT NULL,
continuous_drop_off smallint NOT NULL,
point GEOMETRY(POINT, 4326),
-- point GEOMETRY(POINT, 4326),
route_id text NOT NULL,
chateau text NOT NULL,
PRIMARY KEY (onestop_feed_id, attempt_id, trip_id, stop_sequence)
Expand Down
18 changes: 4 additions & 14 deletions src/maple/gtfs_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ pub async fn gtfs_process_feed(

//insert trip
for (trip_id, trip) in &gtfs.trips {

let mut stop_headsigns: HashSet<String> = HashSet::new();

for stop_time in &trip.stop_times {
Expand Down Expand Up @@ -292,14 +293,15 @@ pub async fn gtfs_process_feed(
let stop_times_pg = trip
.stop_times
.iter()
.map(|stop_time| catenary::models::StopTime {
.enumerate()
.map(|(stop_time_i, stop_time)| catenary::models::StopTime {
onestop_feed_id: feed_id.to_string(),
route_id: trip.route_id.clone(),
stop_headsign_translations: None,
trip_id: trip_id.clone(),
attempt_id: attempt_id.to_string(),
stop_id: stop_time.stop.id.clone(),
stop_sequence: stop_time.stop_sequence as i32,
stop_sequence: stop_time_i as i32,
arrival_time: stop_time.arrival_time,
departure_time: stop_time.departure_time,
stop_headsign: stop_time.stop_headsign.clone(),
Expand All @@ -311,18 +313,6 @@ pub async fn gtfs_process_feed(
gtfs_structures::TimepointType::Approximate => false,
},
chateau: chateau_id.to_string(),
point: match stop_time.stop.latitude {
Some(latitude) => match stop_time.stop.longitude {
Some(longitude) => Some(postgis_diesel::types::Point {
srid: Some(catenary::WGS_84_SRID),
x: longitude,
y: latitude,
}),
None => None,
},
None => None,
},

continuous_pickup: continuous_pickup_drop_off_to_i16(&stop_time.continuous_pickup),
continuous_drop_off: continuous_pickup_drop_off_to_i16(
&stop_time.continuous_drop_off,
Expand Down
2 changes: 1 addition & 1 deletion src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ pub struct StopTime {
pub timepoint: bool,
pub continuous_pickup: i16,
pub continuous_drop_off: i16,
pub point: Option<postgis_diesel::types::Point>,
// pub point: Option<postgis_diesel::types::Point>,
pub route_id: String,
pub chateau: String,
}
Expand Down

0 comments on commit d0bf545

Please sign in to comment.