Skip to content

Commit

Permalink
TODOs and format
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkirk committed May 29, 2024
1 parent 06e92b7 commit 3b0593f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
28 changes: 10 additions & 18 deletions services/travelmux/src/api/v6/osrm_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
}
}
Expand All @@ -186,8 +178,8 @@ impl RouteStep {
pub struct VisualInstructionBanner {
pub distance_along_geometry: f64,
pub primary: VisualInstruction,
// secondary: Option<BannerInstructionContent>,
// sub: Option<BannerInstructionContent>,
// secondary: Option<BannerInstructionContent>, // TODO
// sub: Option<BannerInstructionContent>, // TODO
}

impl VisualInstructionBanner {
Expand Down Expand Up @@ -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),
}

Expand Down
23 changes: 14 additions & 9 deletions services/travelmux/src/api/v6/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)]
Expand Down Expand Up @@ -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}."))
Expand All @@ -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())
Expand Down Expand Up @@ -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)
})
Expand Down

0 comments on commit 3b0593f

Please sign in to comment.