From 3b0593ffde6ada8deba947a344a7642329521693 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 29 May 2024 16:42:44 -0700 Subject: [PATCH] TODOs and format --- services/travelmux/src/api/v6/osrm_api.rs | 28 ++++++++--------------- services/travelmux/src/api/v6/plan.rs | 23 +++++++++++-------- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/services/travelmux/src/api/v6/osrm_api.rs b/services/travelmux/src/api/v6/osrm_api.rs index aae3cae33..918bf0631 100644 --- a/services/travelmux/src/api/v6/osrm_api.rs +++ b/services/travelmux/src/api/v6/osrm_api.rs @@ -81,12 +81,7 @@ impl RouteLeg { .map(|this_and_next| { let maneuver = this_and_next[0].clone(); let next_maneuver = this_and_next.get(1); - RouteStep::from_maneuver( - maneuver, - next_maneuver, - value.mode, - distance_unit, - ) + RouteStep::from_maneuver(maneuver, next_maneuver, value.mode, distance_unit) }) .collect(); if let Some(final_maneuver) = non_transit_leg.maneuvers.last() { @@ -155,11 +150,8 @@ impl RouteStep { mode: TravelMode, from_distance_unit: DistanceUnit, ) -> Self { - let banner_instructions = VisualInstructionBanner::from_maneuver( - &maneuver, - next_maneuver, - from_distance_unit, - ); + let banner_instructions = + VisualInstructionBanner::from_maneuver(&maneuver, next_maneuver, from_distance_unit); RouteStep { distance: maneuver.distance_meters(from_distance_unit), duration: maneuver.duration_seconds, @@ -168,14 +160,14 @@ impl RouteStep { .street_names .unwrap_or(vec!["".to_string()]) .join(", "), - r#ref: None, - pronunciation: None, - destinations: None, + r#ref: None, // TODO + pronunciation: None, // TODO + destinations: None, // TODO mode, maneuver: StepManeuver { location: maneuver.start_point.into(), }, - intersections: None, //vec![], + intersections: None, // TODO banner_instructions, } } @@ -186,8 +178,8 @@ impl RouteStep { pub struct VisualInstructionBanner { pub distance_along_geometry: f64, pub primary: VisualInstruction, - // secondary: Option, - // sub: Option, + // secondary: Option, // TODO + // sub: Option, // TODO } impl VisualInstructionBanner { @@ -454,7 +446,7 @@ pub enum BannerComponent { /// If the two adjacent components are both displayed as images, you can hide this delimiter component. Delimiter(VisualInstructionComponent), - #[allow(unused)] + #[allow(unused)] // TODO Lane(LaneIndicationComponent), } diff --git a/services/travelmux/src/api/v6/plan.rs b/services/travelmux/src/api/v6/plan.rs index 728d32d52..365279807 100644 --- a/services/travelmux/src/api/v6/plan.rs +++ b/services/travelmux/src/api/v6/plan.rs @@ -219,14 +219,10 @@ pub(crate) struct Leg { /// End of the Leg to_place: Place, - // This is mostly OTP specific. We can synthesize a value from the valhalla response, but we - // don't currently use it. /// Start time of the leg #[serde(serialize_with = "serialize_system_time_as_millis")] start_time: SystemTime, - // This is mostly OTP specific. We can synthesize a value from the valhalla response, but we - // don't currently use it. /// Start time of the leg #[serde(serialize_with = "serialize_system_time_as_millis")] end_time: SystemTime, @@ -238,7 +234,7 @@ pub(crate) struct Leg { pub(crate) duration_seconds: f64, } -// Should we just pass the entire OTP leg? +// Currently we just pass the entire OTP leg type TransitLeg = otp_api::Leg; #[derive(Debug, Serialize, Clone, PartialEq)] @@ -421,7 +417,9 @@ fn maneuver_instruction( Some("Depart.".to_string()) } } - otp_api::RelativeDirection::HardLeft => Some(format!("Turn left onto {street_name}.")), + otp_api::RelativeDirection::HardLeft => { + Some(format!("Turn sharp left onto {street_name}.")) + } otp_api::RelativeDirection::Left => Some(format!("Turn left onto {street_name}.")), otp_api::RelativeDirection::SlightlyLeft => { Some(format!("Turn slightly left onto {street_name}.")) @@ -431,7 +429,9 @@ fn maneuver_instruction( Some(format!("Turn slightly right onto {street_name}.")) } otp_api::RelativeDirection::Right => Some(format!("Turn right onto {street_name}.")), - otp_api::RelativeDirection::HardRight => Some(format!("Turn right onto {street_name}.")), + otp_api::RelativeDirection::HardRight => { + Some(format!("Turn sharp right onto {street_name}.")) + } otp_api::RelativeDirection::CircleClockwise | otp_api::RelativeDirection::CircleCounterclockwise => { Some("Enter the roundabout.".to_string()) @@ -492,8 +492,13 @@ impl Leg { .cloned() .map(|otp_step| { // compute step geometry by distance along leg geometry - let step_geometry = - segmenter.next_segment(otp_step.distance).expect("TODO"); + let step_geometry = segmenter + .next_segment(otp_step.distance) + .unwrap_or_else(|| { + log::warn!("no geometry for step"); + debug_assert!(false, "no geometry for step"); + LineString::new(vec![]) + }); distance_so_far += otp_step.distance; Maneuver::from_otp(otp_step, step_geometry, otp, distance_unit) })