mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 07:25:47 +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:
|
should first make sure your .osm has been clipped:
|
||||||
`osmconvert large_map.osm -B=clipping.poly --complete-ways -o=smaller_map.osm`.
|
`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
|
By default, driving on the right is assumed. Use `--oneshot_drive_on_left` to
|
||||||
touch if you need these fixed soon or want to help.
|
invert.
|
||||||
|
|
||||||
### How to get .osm files
|
### How to get .osm files
|
||||||
|
|
||||||
If the area is small enough, try the "export" tool on
|
If the area is small enough, try the "export" tool on
|
||||||
<https://www.openstreetmap.org>. You can download larger areas from
|
<https://www.openstreetmap.org>. You can download larger areas from
|
||||||
<https://download.bbbike.org/> or <http://download.geofabrik.de/index.html>,
|
<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
|
[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
|
region you want to simulate and save the geojson locally. Use
|
||||||
geojson_to_osmosis < boundary.geojson > clipping.poly` to convert that geojson
|
`cargo run --bin geojson_to_osmosis < boundary.geojson > clipping.poly` to
|
||||||
to the [Osmosis
|
convert that geojson to the
|
||||||
format](https://wiki.openstreetmap.org/wiki/Osmosis/Polygon_Filter_File_Format)
|
[Osmosis format](https://wiki.openstreetmap.org/wiki/Osmosis/Polygon_Filter_File_Format)
|
||||||
required by osmconvert.
|
required by osmconvert.
|
||||||
|
|
||||||
## Including the city to A/B street more permanently
|
## 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
|
[geoman.io](https://geoman.io/geojson-editor) to draw a boundary around the
|
||||||
region you want to simulate and save the geojson locally.
|
region you want to simulate and save the geojson locally.
|
||||||
|
|
||||||
4. Use `cargo run --bin geojson_to_osmosis < boundary.geojson > clipping.poly` to
|
4. Use `cargo run --bin geojson_to_osmosis < boundary.geojson > clipping.poly`
|
||||||
convert that geojson to the [Osmosis
|
to convert that geojson to the
|
||||||
format](https://wiki.openstreetmap.org/wiki/Osmosis/Polygon_Filter_File_Format)
|
[Osmosis format](https://wiki.openstreetmap.org/wiki/Osmosis/Polygon_Filter_File_Format)
|
||||||
required by osmconvert.
|
required by osmconvert.
|
||||||
|
|
||||||
5. Create a new module in `importer/src/` for your city, copying
|
5. Create a new module in `importer/src/` for your city, copying
|
||||||
|
@ -217,16 +217,16 @@ impl TurnExplorer {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
let (vehicles, bike) = app
|
||||||
.primary
|
.primary
|
||||||
.sim
|
.sim
|
||||||
.target_lane_penalty(app.primary.map.get_l(turns[idx - 1].id.dst));
|
.target_lane_penalty(app.primary.map.get_l(turns[idx - 1].id.dst));
|
||||||
col.push(
|
col.push(
|
||||||
format!(
|
format!(
|
||||||
"Penalties: {} for lane types, {} for lane changing, {} for keeping right, {} \
|
"Penalties: {} for lane types, {} for lane changing, {} for keeping to the \
|
||||||
for vehicles, {} for slow bikes",
|
slow lane, {} for vehicles, {} for slow bikes",
|
||||||
lt, lc, rightmost, vehicles, bike
|
lt, lc, slow_lane, vehicles, bike
|
||||||
)
|
)
|
||||||
.draw_text(ctx),
|
.draw_text(ctx),
|
||||||
);
|
);
|
||||||
|
@ -109,13 +109,13 @@ impl Turn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO Maybe precompute this.
|
// 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) {
|
pub fn penalty(&self, map: &Map) -> (usize, usize, usize) {
|
||||||
let from = map.get_l(self.id.src);
|
let from = map.get_l(self.id.src);
|
||||||
let to = map.get_l(self.id.dst);
|
let to = map.get_l(self.id.dst);
|
||||||
|
|
||||||
// Starting from the right / farthest from the center line, where is this travel lane?
|
// Starting from the farthest from the center line (right in the US), where is this travel
|
||||||
// Filters by the lane type and ignores lanes that don't go to the target road.
|
// lane? Filters by the lane type and ignores lanes that don't go to the target road.
|
||||||
let from_idx = {
|
let from_idx = {
|
||||||
let mut cnt = 0;
|
let mut cnt = 0;
|
||||||
let r = map.get_r(from.parent);
|
let r = map.get_r(from.parent);
|
||||||
@ -137,8 +137,8 @@ impl Turn {
|
|||||||
cnt
|
cnt
|
||||||
};
|
};
|
||||||
|
|
||||||
// Starting from the right / farthest from the center line, where is this travel lane?
|
// Starting from the farthest from the center line (right in the US), where is this travel
|
||||||
// Filters by the lane type.
|
// lane? Filters by the lane type.
|
||||||
let to_idx = {
|
let to_idx = {
|
||||||
let mut cnt = 0;
|
let mut cnt = 0;
|
||||||
let r = map.get_r(to.parent);
|
let r = map.get_r(to.parent);
|
||||||
@ -166,10 +166,10 @@ impl Turn {
|
|||||||
// matter.
|
// matter.
|
||||||
let lt_cost = if to.is_biking() || to.is_bus() { 0 } else { 1 };
|
let lt_cost = if to.is_biking() || to.is_bus() { 0 } else { 1 };
|
||||||
|
|
||||||
// Keep right
|
// Keep right (in the US)
|
||||||
let rightmost = if to_idx > 1 { 1 } else { 0 };
|
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
|
// Normally opportunistic lane-changing adjusts the path live, but that doesn't work near
|
||||||
// uber-turns. So still use some of the penalties here.
|
// 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
|
// TODO Since these costs wind up mattering most for particular lane choice, I guess just
|
||||||
// adding is reasonable?
|
// adding is reasonable?
|
||||||
let mut extra_penalty = lt + lc;
|
let mut extra_penalty = lt + lc;
|
||||||
if constraints == PathConstraints::Bike {
|
if constraints == PathConstraints::Bike {
|
||||||
extra_penalty = rightmost;
|
extra_penalty = slow_lane;
|
||||||
}
|
}
|
||||||
|
|
||||||
base + extra_penalty
|
base + extra_penalty
|
||||||
|
@ -378,7 +378,7 @@ impl Router {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map(|(turn1, l, turn2)| {
|
.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();
|
let (vehicles, mut bike) = queues[&Traversable::Lane(l)].target_lane_penalty();
|
||||||
|
|
||||||
// The magic happens here. We have different penalties:
|
// The magic happens here. We have different penalties:
|
||||||
@ -387,7 +387,8 @@ impl Router {
|
|||||||
// lane?
|
// lane?
|
||||||
// 2) Are there any bikes in the target lane? This ONLY matters if we're a car. If
|
// 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.
|
// 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?
|
// 4) Are there lots of vehicles stacked up in one lane?
|
||||||
// 5) Are we changing lanes?
|
// 5) Are we changing lanes?
|
||||||
//
|
//
|
||||||
@ -397,9 +398,9 @@ impl Router {
|
|||||||
if self.owner.1 == VehicleType::Bike {
|
if self.owner.1 == VehicleType::Bike {
|
||||||
bike = 0;
|
bike = 0;
|
||||||
} else {
|
} 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)
|
(cost, turn1, l, turn2)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user