Skip to content

Commit

Permalink
Don't show walking/cycling routes by default. #951
Browse files Browse the repository at this point in the history
This was added to show people how direct the non-car trip is, but the UI
is overwhelming right now with 4 routes. Still let people see more info,
but don't overload them to start.
  • Loading branch information
dabreegster committed Sep 5, 2022
1 parent d2c0253 commit 48accc6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
2 changes: 2 additions & 0 deletions apps/ltn/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ fn run(mut settings: Settings) {
draw_neighbourhood_style: browse::Style::Simple,
heuristic: filters::auto::Heuristic::SplitCells,
main_road_penalty: 1.0,
show_walking_cycling_routes: false,

current_trip_name: None,

Expand Down Expand Up @@ -291,6 +292,7 @@ pub struct Session {
pub heuristic: filters::auto::Heuristic,
// Pathfinding
pub main_road_penalty: f64,
pub show_walking_cycling_routes: bool,

current_trip_name: Option<String>,

Expand Down
34 changes: 26 additions & 8 deletions apps/ltn/src/route_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use synthpop::{TripEndpoint, TripMode};
use widgetry::mapspace::World;
use widgetry::{
ButtonBuilder, Color, ControlState, Drawable, EventCtx, GeomBatch, GfxCtx, Key, Line, Outcome,
Panel, RoundedF64, Spinner, State, Text, Widget,
Panel, RoundedF64, Spinner, State, Text, Toggle, Widget,
};

use crate::components::Mode;
Expand Down Expand Up @@ -202,7 +202,7 @@ impl RoutePlanner {
total_time
};

let biking_time = {
let biking_time = if app.session.show_walking_cycling_routes {
// No custom params, but don't use the map's built-in bike CH. Changes to one-way
// streets haven't been reflected, and it's cheap enough to use Dijkstra's for
// calculating one path at a time anyway.
Expand All @@ -222,9 +222,11 @@ impl RoutePlanner {
}
}
total_time
} else {
Duration::ZERO
};

let walking_time = {
let walking_time = if app.session.show_walking_cycling_routes {
// Same as above -- don't use the built-in CH.
let mut total_time = Duration::ZERO;
for pair in self.waypoints.get_waypoints().windows(2) {
Expand All @@ -242,6 +244,8 @@ impl RoutePlanner {
}
}
total_time
} else {
Duration::ZERO
};

self.draw_routes = map_gui::tools::draw_overlapping_paths(app, paths)
Expand Down Expand Up @@ -279,11 +283,21 @@ impl RoutePlanner {
},
])
.evenly_spaced(),
Widget::row(vec![
card(ctx, "Cycling", "This cycling route doesn't avoid high-stress roads or hills, and assumes an average 10mph pace", biking_time, *colors::PLAN_ROUTE_BIKE),
card(ctx, "Walking", "This walking route doesn't avoid high-stress roads or hills, and assumes an average 3 mph pace", walking_time, *colors::PLAN_ROUTE_WALK),
])
.evenly_spaced(),
if app.session.show_walking_cycling_routes {
Widget::row(vec![
card(ctx, "Cycling", "This cycling route doesn't avoid high-stress roads or hills, and assumes an average 10mph pace", biking_time, *colors::PLAN_ROUTE_BIKE),
card(ctx, "Walking", "This walking route doesn't avoid high-stress roads or hills, and assumes an average 3 mph pace", walking_time, *colors::PLAN_ROUTE_WALK),
])
.evenly_spaced()
} else {
Widget::nothing()
},
Toggle::checkbox(
ctx,
"Show walking & cycling route",
None,
app.session.show_walking_cycling_routes,
),
])
}
}
Expand Down Expand Up @@ -327,6 +341,10 @@ impl State<App> for RoutePlanner {
app.session.main_road_penalty =
self.left_panel.spinner::<RoundedF64>("main road penalty").0;
self.update_everything(ctx, app);
} else if x == "Show walking & cycling route" {
app.session.show_walking_cycling_routes =
self.left_panel.is_checked("Show walking & cycling route");
self.update_everything(ctx, app);
}
}

Expand Down

0 comments on commit 48accc6

Please sign in to comment.