Skip to content

Commit

Permalink
[travelmux] plan/v4 api returns transit plan
Browse files Browse the repository at this point in the history
Note 1: though the frontend is "using" the /v4 API, it's still peaking
into the raw _otp response.

Note 2: I removed OtpTravelMode.Train - it seems like it never existed.
Was I hallucinating?
  • Loading branch information
michaelkirk committed Apr 6, 2024
1 parent 6f9ac7f commit 0df5b4a
Show file tree
Hide file tree
Showing 9 changed files with 330 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export enum OTPMode {
Gondola = 'GONDOLA',
Rail = 'RAIL',
Subway = 'SUBWAY',
Train = 'TRAIN',
Tram = 'TRAM',
Transit = 'TRANSIT',
Walk = 'WALK',
Expand Down
2 changes: 1 addition & 1 deletion services/frontend/www-app/src/services/TravelmuxClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class TravelmuxClient {

const query = new URLSearchParams(params).toString();

const response = await fetch('/travelmux/v3/plan?' + query);
const response = await fetch('/travelmux/v4/plan?' + query);

if (response.ok) {
const travelmuxResponseJson: TravelmuxPlanResponse =
Expand Down
12 changes: 12 additions & 0 deletions services/travelmux/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions services/travelmux/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ polyline = "0.10.1"
reqwest = { version = "0.11.13", features = ["json", "stream"] }
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.91"
serde_repr = "0.1.18"
url = "2.4.0"
wkt = "0.10.3"

Expand Down
6 changes: 4 additions & 2 deletions services/travelmux/src/api/v2/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ struct Leg {
maneuvers: Option<Vec<Maneuver>>,
}

pub type ManeuverType = valhalla_api::ManeuverType;

// Eventually we might want to coalesce this into something not valhalla specific
// but for now we only use it for valhalla trips
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
Expand All @@ -233,7 +235,7 @@ pub struct Maneuver {
pub time: f64,
pub travel_mode: String,
pub travel_type: String,
pub r#type: u64,
pub r#type: ManeuverType,
pub verbal_post_transition_instruction: Option<String>,
pub verbal_pre_transition_instruction: Option<String>,
pub verbal_succinct_transition_instruction: Option<String>,
Expand Down Expand Up @@ -548,7 +550,7 @@ mod tests {
}"#;

let valhalla_maneuver: valhalla_api::Maneuver = serde_json::from_str(json).unwrap();
assert_eq!(valhalla_maneuver.r#type, 2);
assert_eq!(valhalla_maneuver.r#type, ManeuverType::StartRight);
assert_eq!(
valhalla_maneuver.instruction,
"Drive northeast on Fauntleroy Way Southwest."
Expand Down
5 changes: 3 additions & 2 deletions services/travelmux/src/api/v3/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub struct PlanQuery {
}

use crate::error::ErrorType;
use crate::valhalla::valhalla_api::ManeuverType;
use error::PlanResponseErr;

#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
Expand Down Expand Up @@ -340,7 +341,7 @@ pub struct Maneuver {
pub time: f64,
pub travel_mode: String,
pub travel_type: String,
pub r#type: u64,
pub r#type: ManeuverType,
pub verbal_post_transition_instruction: Option<String>,
pub verbal_pre_transition_instruction: Option<String>,
pub verbal_succinct_transition_instruction: Option<String>,
Expand Down Expand Up @@ -685,7 +686,7 @@ mod tests {
}"#;

let valhalla_maneuver: valhalla_api::Maneuver = serde_json::from_str(json).unwrap();
assert_eq!(valhalla_maneuver.r#type, 2);
assert_eq!(valhalla_maneuver.r#type, ManeuverType::StartRight);
assert_eq!(
valhalla_maneuver.instruction,
"Drive northeast on Fauntleroy Way Southwest."
Expand Down
Loading

0 comments on commit 0df5b4a

Please sign in to comment.