-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support incidents for OSRM responses #358
base: main
Are you sure you want to change the base?
Conversation
@@ -500,4 +535,88 @@ mod tests { | |||
Some(vec!["right".to_string()]) | |||
); | |||
} | |||
|
|||
#[test] | |||
fn deserialize_incidents() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i got this example from hitting the api with points of -71.078874,42.376381 to -73.900821,40.659135 using the traffic routing profile.
the documentation has a lot of details about the objects, but no sample unfortunately. i also found some things that came back from their api call that weren't in their documentation, so i intentionally left those out (ex length, affected_road_names_unknown, etc).
00b5679
to
1520125
Compare
@@ -322,6 +322,8 @@ pub struct RouteStep { | |||
pub spoken_instructions: Vec<SpokenInstruction>, | |||
/// A list of json encoded strings representing annotations between each coordinate along the step. | |||
pub annotations: Option<Vec<String>>, | |||
/// A list of incidents that occur along the step. | |||
pub incidents: Vec<Incident>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thinking out loud - this is provided via the API as a "per leg" response, not a "per step" response. the indices for the start and stop of the incident in the coordinates is therefore global and not localized per step. does it make sense to move this into the step level and convert and split this so it belongs to each step instead? we would just use the indices as the way to do that - the complication would be if a particular incident "spans" more than one leg, we'd need to actually duplicate it. thoughts?
update - i just realized, that's what i am doing here and i just didn't realize it - but my logic is wrong in common/ferrostar/src/routing_adapters/osrm/mod.rs
, since i need to also slice these just like we're doing with annotations. will mark this as a draft while i fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, but please see the discussion below for some trade-offs.
@@ -126,6 +133,7 @@ impl Route { | |||
step, | |||
step_geometry, | |||
annotation_slice, | |||
incident_items.clone(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i need to fix this - this shouldn't be all the items, just the items relevant to this step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, but please see the discussion below for some trade-offs.
1520125
to
2d1161b
Compare
This parses incidents on the OSRM response route leg, and splits the incidents across the corresponding route step. Since an incident may span multiple steps, this will duplicate an incident and adjust the indices accordingly whenever that happens. Clients can de-duplicate these if necessary based on the incident identifier.
2d1161b
to
93b0995
Compare
@ianthetechie would appreciate your input here, since we have a few possible solutions that we were discussing internally, each with their set of pros and cons (we chose one of the solutions for this PR) - but want to know what you'd recommend. The ProblemMapbox's SDK emits Possible SolutionsIncidents on LegsKeep
Incidents on RoutesKeep
|
also, i am not sure why
|
This parses incidents on the OSRM response route leg, and splits the
incidents across the corresponding route step. Since an incident may
span multiple steps, this will duplicate an incident and adjust the
indices accordingly whenever that happens. Clients can de-duplicate
these if necessary based on the incident identifier.