Skip to content

Commit

Permalink
Merge pull request #834 from CanalTP/remove_datetime_estimated_field
Browse files Browse the repository at this point in the history
[feature] Remove datetime estimated field
  • Loading branch information
patochectp authored Jan 6, 2022
2 parents 6220673 + 260c317 commit 91e3dda
Show file tree
Hide file tree
Showing 22 changed files with 268 additions and 318 deletions.
1 change: 0 additions & 1 deletion model-builder/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ impl<'a> VehicleJourneyBuilder<'a> {
alighting_duration: 0u16,
pickup_type: 0u8,
drop_off_type: 0u8,
datetime_estimated: false,
local_zone_id: None,
precision: None,
};
Expand Down
2 changes: 0 additions & 2 deletions src/enhancers/check_stop_times_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: None,
precision: None,
},
Expand All @@ -54,7 +53,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: None,
precision: None,
},
Expand Down
5 changes: 0 additions & 5 deletions src/enhancers/enhance_pickup_dropoff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: None,
precision: None,
};
Expand All @@ -223,7 +222,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: None,
precision: None,
};
Expand All @@ -237,7 +235,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: None,
precision: None,
};
Expand All @@ -251,7 +248,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: None,
precision: None,
};
Expand Down Expand Up @@ -463,7 +459,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 3,
drop_off_type: 3,
datetime_estimated: true,
local_zone_id: None,
precision: None,
});
Expand Down
38 changes: 14 additions & 24 deletions src/gtfs/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,14 @@ where

for (stop_time, st_values) in stop_times.iter().zip(st_values) {
if let Some(stop_point_idx) = collections.stop_points.get_idx(&stop_time.stop_id) {
let precision = match (on_demand_transport, st_values.datetime_estimated) {
(_, false) => Some(StopTimePrecision::Exact),
(false, true) => Some(StopTimePrecision::Approximate),
(true, true) => Some(StopTimePrecision::Estimated),
let precision = if on_demand_transport
&& st_values.precision == StopTimePrecision::Approximate
{
Some(StopTimePrecision::Estimated)
} else {
Some(st_values.precision)
};

if let Some(headsign) = &stop_time.stop_headsign {
headsigns.insert(
(stop_time.trip_id.clone(), stop_time.stop_sequence),
Expand Down Expand Up @@ -461,7 +464,6 @@ where
alighting_duration: 0,
pickup_type,
drop_off_type,
datetime_estimated: st_values.datetime_estimated,
local_zone_id: stop_time.local_zone_id,
precision,
});
Expand Down Expand Up @@ -493,7 +495,7 @@ fn ventilate_stop_times(
res.push(StopTimesValues {
departure_time: time,
arrival_time: time,
datetime_estimated: true,
precision: StopTimePrecision::Approximate,
});
}
res
Expand All @@ -503,7 +505,7 @@ fn ventilate_stop_times(
struct StopTimesValues {
arrival_time: Time,
departure_time: Time,
datetime_estimated: bool,
precision: StopTimePrecision,
}

// in the GTFS some stoptime can have undefined departure/arrival (all stop_times but the first and the last)
Expand Down Expand Up @@ -536,7 +538,11 @@ fn interpolate_undefined_stop_times(
let st_value = StopTimesValues {
departure_time,
arrival_time,
datetime_estimated: !st.timepoint,
precision: if !st.timepoint {
StopTimePrecision::Approximate
} else {
StopTimePrecision::Exact
},
};

if !undefined_stops_bulk.is_empty() {
Expand Down Expand Up @@ -1209,10 +1215,6 @@ where
);
continue;
}
let datetime_estimated = match frequency.exact_times {
FrequencyPrecision::Exact => false,
FrequencyPrecision::Inexact => true,
};
let corresponding_vj = skip_error_and_warn!(collections
.vehicle_journeys
.get(&frequency.trip_id)
Expand Down Expand Up @@ -1281,7 +1283,6 @@ where
alighting_duration: stop_time.alighting_duration,
pickup_type: stop_time.pickup_type,
drop_off_type: stop_time.drop_off_type,
datetime_estimated,
local_zone_id: stop_time.local_zone_id,
precision: stop_time.precision.clone(),
})
Expand Down Expand Up @@ -2511,7 +2512,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: true,
local_zone_id: None,
precision: Some(StopTimePrecision::Approximate),
},
Expand All @@ -2524,7 +2524,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 2,
drop_off_type: 1,
datetime_estimated: false,
local_zone_id: None,
precision: Some(StopTimePrecision::Exact),
},
Expand All @@ -2537,7 +2536,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 2,
drop_off_type: 1,
datetime_estimated: false,
local_zone_id: None,
precision: Some(StopTimePrecision::Exact),
},
Expand Down Expand Up @@ -2606,7 +2604,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: None,
precision: Some(StopTimePrecision::Exact),
},
Expand All @@ -2619,7 +2616,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: None,
precision: Some(StopTimePrecision::Exact),
},
Expand All @@ -2632,7 +2628,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: None,
precision: Some(StopTimePrecision::Exact),
},
Expand Down Expand Up @@ -2692,7 +2687,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: None,
precision: Some(StopTimePrecision::Exact),
},
Expand All @@ -2705,7 +2699,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 2,
drop_off_type: 1,
datetime_estimated: false,
local_zone_id: None,
precision: Some(StopTimePrecision::Exact),
},
Expand Down Expand Up @@ -3317,7 +3310,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: true,
local_zone_id: None,
precision: Some(StopTimePrecision::Estimated),
},
Expand All @@ -3330,7 +3322,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 2,
drop_off_type: 1,
datetime_estimated: false,
local_zone_id: None,
precision: Some(StopTimePrecision::Exact),
},
Expand All @@ -3343,7 +3334,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 2,
drop_off_type: 1,
datetime_estimated: false,
local_zone_id: None,
precision: Some(StopTimePrecision::Exact),
},
Expand Down
10 changes: 2 additions & 8 deletions src/gtfs/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ pub fn write_stop_times(
stop_headsign: stop_times_headsigns
.get(&(vehicle_journeys[vj_idx].id.clone(), st.sequence))
.cloned(),
timepoint: !st.datetime_estimated,
timepoint: matches!(st.precision, None | Some(StopTimePrecision::Exact)),
})
.with_context(|| format!("Error reading {:?}", st_wtr))?;
}
Expand Down Expand Up @@ -904,7 +904,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 1,
datetime_estimated: false,
local_zone_id: None,
precision: None,
},
Expand All @@ -917,7 +916,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: None,
precision: None,
},
Expand Down Expand Up @@ -949,7 +947,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 1,
datetime_estimated: false,
local_zone_id: None,
precision: None,
},
Expand All @@ -962,7 +959,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: None,
precision: None,
},
Expand Down Expand Up @@ -1178,7 +1174,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: None,
precision: None,
},
Expand All @@ -1191,9 +1186,8 @@ mod tests {
alighting_duration: 0,
pickup_type: 2,
drop_off_type: 1,
datetime_estimated: true,
local_zone_id: Some(3),
precision: None,
precision: Some(StopTimePrecision::Estimated),
},
];
let vehicle_journeys = CollectionWithId::from(VehicleJourney {
Expand Down
2 changes: 0 additions & 2 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: Some(0),
precision: None,
};
Expand Down Expand Up @@ -1828,7 +1827,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: None,
precision: None,
};
Expand Down
7 changes: 0 additions & 7 deletions src/netex_france/offer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: Some(1),
precision: Some(StopTimePrecision::Exact),
},
Expand All @@ -821,7 +820,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 1,
drop_off_type: 1,
datetime_estimated: false,
local_zone_id: Some(1),
precision: Some(StopTimePrecision::Exact),
},
Expand Down Expand Up @@ -853,7 +851,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: Some(1),
precision: Some(StopTimePrecision::Exact),
},
Expand All @@ -866,7 +863,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 1,
drop_off_type: 1,
datetime_estimated: false,
local_zone_id: Some(1),
precision: Some(StopTimePrecision::Exact),
},
Expand Down Expand Up @@ -909,7 +905,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: Some(1),
precision: Some(StopTimePrecision::Exact),
}],
Expand Down Expand Up @@ -958,7 +953,6 @@ mod tests {
// This pickup type is different from 'vj_id_1'
pickup_type: 1,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: Some(1),
precision: Some(StopTimePrecision::Exact),
},
Expand All @@ -971,7 +965,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 1,
drop_off_type: 1,
datetime_estimated: false,
local_zone_id: Some(1),
precision: Some(StopTimePrecision::Exact),
},
Expand Down
1 change: 0 additions & 1 deletion src/netex_france/route_points.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ mod tests {
alighting_duration: 0,
pickup_type: 0,
drop_off_type: 0,
datetime_estimated: false,
local_zone_id: None,
precision: None,
}
Expand Down
Loading

0 comments on commit 91e3dda

Please sign in to comment.