mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-24 23:15:24 +03:00
Cleanup last few things for left-hand maps. Fixes #311!
This commit is contained in:
parent
033b20f004
commit
037e22e69e
@ -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
|
||||
<https://www.openstreetmap.org>. You can download larger areas from
|
||||
<https://download.bbbike.org/> or <http://download.geofabrik.de/index.html>,
|
||||
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
|
||||
|
@ -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),
|
||||
);
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user