From 037e22e69e2ace9c865084165e4e336150615bd3 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Fri, 11 Sep 2020 14:17:31 -0700 Subject: [PATCH] Cleanup last few things for left-hand maps. Fixes #311! --- book/src/howto/new_city.md | 20 ++++++++++---------- game/src/sandbox/misc_tools.rs | 8 ++++---- map_model/src/objects/turn.rs | 16 ++++++++-------- map_model/src/pathfind/driving.rs | 4 ++-- sim/src/router.rs | 9 +++++---- 5 files changed, 29 insertions(+), 28 deletions(-) diff --git a/book/src/howto/new_city.md b/book/src/howto/new_city.md index 88786cc952..a7dffcf0a4 100644 --- a/book/src/howto/new_city.md +++ b/book/src/howto/new_city.md @@ -25,20 +25,20 @@ below), you can also pass `--oneshot_clip=clip.poly` to improve the result. You should first make sure your .osm has been clipped: `osmconvert large_map.osm -B=clipping.poly --complete-ways -o=smaller_map.osm`. -You can also try `--oneshot_drive_on_left`, but you'll spot some bugs. Get in -touch if you need these fixed soon or want to help. +By default, driving on the right is assumed. Use `--oneshot_drive_on_left` to +invert. ### How to get .osm files If the area is small enough, try the "export" tool on . You can download larger areas from or , -then clip them to a smaller area. Use [geojson.io](http://geojson.io/) or +then clip them to a smaller area. Use [geojson.io](http://geojson.io/) or [geoman.io](https://geoman.io/geojson-editor) to draw a boundary around the -region you want to simulate and save the geojson locally. Use `cargo run --bin -geojson_to_osmosis < boundary.geojson > clipping.poly` to convert that geojson -to the [Osmosis -format](https://wiki.openstreetmap.org/wiki/Osmosis/Polygon_Filter_File_Format) +region you want to simulate and save the geojson locally. Use +`cargo run --bin geojson_to_osmosis < boundary.geojson > clipping.poly` to +convert that geojson to the +[Osmosis format](https://wiki.openstreetmap.org/wiki/Osmosis/Polygon_Filter_File_Format) required by osmconvert. ## Including the city to A/B street more permanently @@ -56,9 +56,9 @@ use it as well. [geoman.io](https://geoman.io/geojson-editor) to draw a boundary around the region you want to simulate and save the geojson locally. -4. Use `cargo run --bin geojson_to_osmosis < boundary.geojson > clipping.poly` to - convert that geojson to the [Osmosis - format](https://wiki.openstreetmap.org/wiki/Osmosis/Polygon_Filter_File_Format) +4. Use `cargo run --bin geojson_to_osmosis < boundary.geojson > clipping.poly` + to convert that geojson to the + [Osmosis format](https://wiki.openstreetmap.org/wiki/Osmosis/Polygon_Filter_File_Format) required by osmconvert. 5. Create a new module in `importer/src/` for your city, copying diff --git a/game/src/sandbox/misc_tools.rs b/game/src/sandbox/misc_tools.rs index f1a73cc37f..b481cf8942 100644 --- a/game/src/sandbox/misc_tools.rs +++ b/game/src/sandbox/misc_tools.rs @@ -217,16 +217,16 @@ impl TurnExplorer { )); } } else { - let (lt, lc, rightmost) = turns[idx - 1].penalty(&app.primary.map); + let (lt, lc, slow_lane) = turns[idx - 1].penalty(&app.primary.map); let (vehicles, bike) = app .primary .sim .target_lane_penalty(app.primary.map.get_l(turns[idx - 1].id.dst)); col.push( format!( - "Penalties: {} for lane types, {} for lane changing, {} for keeping right, {} \ - for vehicles, {} for slow bikes", - lt, lc, rightmost, vehicles, bike + "Penalties: {} for lane types, {} for lane changing, {} for keeping to the \ + slow lane, {} for vehicles, {} for slow bikes", + lt, lc, slow_lane, vehicles, bike ) .draw_text(ctx), ); diff --git a/map_model/src/objects/turn.rs b/map_model/src/objects/turn.rs index 3518fd29bb..a301a30012 100644 --- a/map_model/src/objects/turn.rs +++ b/map_model/src/objects/turn.rs @@ -109,13 +109,13 @@ impl Turn { } // TODO Maybe precompute this. - // penalties for (lane types, lane-changing, rightmost) + // penalties for (lane types, lane-changing, slow lane) pub fn penalty(&self, map: &Map) -> (usize, usize, usize) { let from = map.get_l(self.id.src); let to = map.get_l(self.id.dst); - // Starting from the right / farthest from the center line, where is this travel lane? - // Filters by the lane type and ignores lanes that don't go to the target road. + // Starting from the farthest from the center line (right in the US), where is this travel + // lane? Filters by the lane type and ignores lanes that don't go to the target road. let from_idx = { let mut cnt = 0; let r = map.get_r(from.parent); @@ -137,8 +137,8 @@ impl Turn { cnt }; - // Starting from the right / farthest from the center line, where is this travel lane? - // Filters by the lane type. + // Starting from the farthest from the center line (right in the US), where is this travel + // lane? Filters by the lane type. let to_idx = { let mut cnt = 0; let r = map.get_r(to.parent); @@ -166,10 +166,10 @@ impl Turn { // matter. let lt_cost = if to.is_biking() || to.is_bus() { 0 } else { 1 }; - // Keep right - let rightmost = if to_idx > 1 { 1 } else { 0 }; + // Keep right (in the US) + let slow_lane = if to_idx > 1 { 1 } else { 0 }; - (lt_cost, lc_cost, rightmost) + (lt_cost, lc_cost, slow_lane) } } diff --git a/map_model/src/pathfind/driving.rs b/map_model/src/pathfind/driving.rs index 319d647886..d137e95906 100644 --- a/map_model/src/pathfind/driving.rs +++ b/map_model/src/pathfind/driving.rs @@ -262,12 +262,12 @@ pub fn driving_cost(lane: &Lane, turn: &Turn, constraints: PathConstraints, map: // Normally opportunistic lane-changing adjusts the path live, but that doesn't work near // uber-turns. So still use some of the penalties here. - let (lt, lc, rightmost) = turn.penalty(map); + let (lt, lc, slow_lane) = turn.penalty(map); // TODO Since these costs wind up mattering most for particular lane choice, I guess just // adding is reasonable? let mut extra_penalty = lt + lc; if constraints == PathConstraints::Bike { - extra_penalty = rightmost; + extra_penalty = slow_lane; } base + extra_penalty diff --git a/sim/src/router.rs b/sim/src/router.rs index 69a3d31c03..b7c773ea3a 100644 --- a/sim/src/router.rs +++ b/sim/src/router.rs @@ -378,7 +378,7 @@ impl Router { } }) .map(|(turn1, l, turn2)| { - let (lt, lc, mut rightmost) = turn1.penalty(map); + let (lt, lc, mut slow_lane) = turn1.penalty(map); let (vehicles, mut bike) = queues[&Traversable::Lane(l)].target_lane_penalty(); // The magic happens here. We have different penalties: @@ -387,7 +387,8 @@ impl Router { // lane? // 2) Are there any bikes in the target lane? This ONLY matters if we're a car. If // we're another bike, the speed difference won't matter. - // 3) IF we're a bike, are we headed to something other than the rightmost lane? + // 3) IF we're a bike, are we headed to something other than the slow (rightmost in + // the US) lane? // 4) Are there lots of vehicles stacked up in one lane? // 5) Are we changing lanes? // @@ -397,9 +398,9 @@ impl Router { if self.owner.1 == VehicleType::Bike { bike = 0; } else { - rightmost = 0; + slow_lane = 0; } - let cost = (lt, bike, rightmost, vehicles, lc); + let cost = (lt, bike, slow_lane, vehicles, lc); (cost, turn1, l, turn2) })