mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-10-26 10:09:22 +03:00
Calculate driving side automatically, stop asking!
Thanks to https://github.com/a-b-street/osm2streets/issues/80
This commit is contained in:
parent
358ae97f02
commit
b606a0c9d8
21
Cargo.lock
generated
21
Cargo.lock
generated
@ -629,6 +629,7 @@ dependencies = [
|
||||
"abstutil",
|
||||
"anyhow",
|
||||
"csv",
|
||||
"driving-side",
|
||||
"fs-err",
|
||||
"geom",
|
||||
"kml",
|
||||
@ -1010,6 +1011,15 @@ version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
||||
|
||||
[[package]]
|
||||
name = "driving-side"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/a-b-street/osm2lanes#997d5ed09c4ec5775111d3dcd306d83aaf50696a"
|
||||
dependencies = [
|
||||
"geo",
|
||||
"geojson",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dwrote"
|
||||
version = "0.11.0"
|
||||
@ -2924,7 +2934,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "osm-tag-schemes"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/a-b-street/osm2lanes#25ac3ccdc862d82293de05c0c3973047d214ea49"
|
||||
source = "git+https://github.com/a-b-street/osm2lanes#997d5ed09c4ec5775111d3dcd306d83aaf50696a"
|
||||
dependencies = [
|
||||
"osm-tags",
|
||||
"strum 0.24.1",
|
||||
@ -2933,7 +2943,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "osm-tags"
|
||||
version = "0.1.1"
|
||||
source = "git+https://github.com/a-b-street/osm2lanes#25ac3ccdc862d82293de05c0c3973047d214ea49"
|
||||
source = "git+https://github.com/a-b-street/osm2lanes#997d5ed09c4ec5775111d3dcd306d83aaf50696a"
|
||||
dependencies = [
|
||||
"kstring",
|
||||
]
|
||||
@ -2941,7 +2951,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "osm2lanes"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/a-b-street/osm2lanes#25ac3ccdc862d82293de05c0c3973047d214ea49"
|
||||
source = "git+https://github.com/a-b-street/osm2lanes#997d5ed09c4ec5775111d3dcd306d83aaf50696a"
|
||||
dependencies = [
|
||||
"celes",
|
||||
"locale-codes",
|
||||
@ -2953,7 +2963,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "osm2streets"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/a-b-street/osm2streets#670bd72acd6d82ef43f325b8f64b12f6700ba68e"
|
||||
source = "git+https://github.com/a-b-street/osm2streets#3230590a4062491e3b1146931217b54618454a57"
|
||||
dependencies = [
|
||||
"aabb-quadtree",
|
||||
"abstutil",
|
||||
@ -3977,10 +3987,11 @@ checksum = "ef5430c8e36b713e13b48a9f709cc21e046723fe44ce34587b73a830203b533e"
|
||||
[[package]]
|
||||
name = "streets_reader"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/a-b-street/osm2streets#670bd72acd6d82ef43f325b8f64b12f6700ba68e"
|
||||
source = "git+https://github.com/a-b-street/osm2streets#3230590a4062491e3b1146931217b54618454a57"
|
||||
dependencies = [
|
||||
"abstutil",
|
||||
"anyhow",
|
||||
"driving-side",
|
||||
"geom",
|
||||
"log",
|
||||
"osm2streets",
|
||||
|
@ -152,9 +152,6 @@ enum Command {
|
||||
/// code), with the city as "oneshot." This name shouldn't contain spaces or be empty.
|
||||
#[structopt(long)]
|
||||
map_name: String,
|
||||
/// Do people drive on the left side of the road in this map?
|
||||
#[structopt(long)]
|
||||
drive_on_left: bool,
|
||||
/// Use Geofabrik to grab OSM input if true, or Overpass if false. Overpass is faster.
|
||||
#[structopt(long)]
|
||||
use_geofabrik: bool,
|
||||
@ -174,9 +171,6 @@ enum Command {
|
||||
/// derived from the .osm file, but borders will likely be broken or missing.
|
||||
#[structopt(long)]
|
||||
clip_path: Option<String>,
|
||||
/// Do people drive on the left side of the road in this map?
|
||||
#[structopt(long)]
|
||||
drive_on_left: bool,
|
||||
/// Downgrade crosswalks not matching a `highway=crossing` OSM node into unmarked crossings.
|
||||
#[structopt(long)]
|
||||
filter_crosswalks: bool,
|
||||
@ -283,7 +277,6 @@ async fn main() -> Result<()> {
|
||||
Command::OneStepImport {
|
||||
geojson_path,
|
||||
map_name,
|
||||
drive_on_left,
|
||||
use_geofabrik,
|
||||
filter_crosswalks,
|
||||
create_uk_travel_demand_model,
|
||||
@ -291,7 +284,6 @@ async fn main() -> Result<()> {
|
||||
one_step_import::run(
|
||||
geojson_path,
|
||||
map_name,
|
||||
driving_side(drive_on_left),
|
||||
use_geofabrik,
|
||||
filter_crosswalks,
|
||||
create_uk_travel_demand_model,
|
||||
@ -301,7 +293,6 @@ async fn main() -> Result<()> {
|
||||
Command::OneshotImport {
|
||||
osm_input,
|
||||
clip_path,
|
||||
drive_on_left,
|
||||
filter_crosswalks,
|
||||
create_uk_travel_demand_model,
|
||||
opts,
|
||||
@ -309,7 +300,6 @@ async fn main() -> Result<()> {
|
||||
importer::oneshot(
|
||||
osm_input,
|
||||
clip_path,
|
||||
driving_side(drive_on_left),
|
||||
filter_crosswalks,
|
||||
create_uk_travel_demand_model,
|
||||
opts,
|
||||
@ -429,11 +419,3 @@ fn prebake_scenario(path: String) {
|
||||
let map = map_model::Map::load_synchronously(scenario.map_name.path(), &mut timer);
|
||||
sim::prebake::prebake(&map, scenario, &mut timer);
|
||||
}
|
||||
|
||||
fn driving_side(drive_on_left: bool) -> map_model::DrivingSide {
|
||||
if drive_on_left {
|
||||
map_model::DrivingSide::Left
|
||||
} else {
|
||||
map_model::DrivingSide::Right
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ use geom::LonLat;
|
||||
pub async fn run(
|
||||
geojson_path: String,
|
||||
name: String,
|
||||
driving_side: map_model::DrivingSide,
|
||||
use_geofabrik: bool,
|
||||
filter_crosswalks: bool,
|
||||
create_uk_travel_demand_model: bool,
|
||||
@ -65,7 +64,6 @@ pub async fn run(
|
||||
importer::oneshot(
|
||||
osm,
|
||||
Some(geojson_path),
|
||||
driving_side,
|
||||
filter_crosswalks,
|
||||
create_uk_travel_demand_model,
|
||||
map_model::RawToMapOptions::default(),
|
||||
|
@ -9,6 +9,7 @@ abstio = { path = "../abstio" }
|
||||
abstutil = { path = "../abstutil" }
|
||||
anyhow = { workspace = true }
|
||||
csv = "1.1.4"
|
||||
driving-side = { git = "https://github.com/a-b-street/osm2lanes" }
|
||||
fs-err = { workspace = true }
|
||||
geom = { path = "../geom" }
|
||||
kml = { path = "../kml" }
|
||||
|
@ -2,7 +2,7 @@ use osm::{OsmID, RelationID, WayID};
|
||||
|
||||
use abstutil::{MultiMap, Tags, Timer};
|
||||
use geom::{Distance, FindClosest, Polygon, Pt2D, Ring};
|
||||
use osm2streets::{osm, NamePerLanguage};
|
||||
use osm2streets::{osm, DrivingSide, NamePerLanguage};
|
||||
use raw_map::{Amenity, AreaType, RawArea, RawBuilding, RawMap, RawParkingLot};
|
||||
|
||||
use crate::Options;
|
||||
@ -44,6 +44,13 @@ pub fn extract_osm(
|
||||
map.streets.gps_bounds = doc.gps_bounds.clone();
|
||||
map.streets.boundary_polygon = map.streets.gps_bounds.to_bounds().get_rectangle();
|
||||
}
|
||||
// Calculate DrivingSide from some arbitrary point
|
||||
map.streets.config.driving_side =
|
||||
if driving_side::is_left_handed(map.streets.gps_bounds.get_rectangle()[0].into()) {
|
||||
DrivingSide::Left
|
||||
} else {
|
||||
DrivingSide::Right
|
||||
};
|
||||
|
||||
let mut out = OsmExtract::new();
|
||||
let mut amenity_points = Vec::new();
|
||||
|
@ -31,7 +31,8 @@ pub fn convert(
|
||||
timer.start("create RawMap from input data");
|
||||
|
||||
let mut map = RawMap::blank(name);
|
||||
// Do this early. Calculating Roads uses DrivingSide, for example!
|
||||
// Note that DrivingSide is still incorrect. It'll be set in extract_osm, before Road::new
|
||||
// happens in split_ways.
|
||||
map.streets.config = opts.map_config.clone();
|
||||
|
||||
if let Some(ref path) = clip_path {
|
||||
|
@ -49,7 +49,6 @@ pub async fn regenerate_everything(shard_num: usize, num_shards: usize) {
|
||||
pub async fn oneshot(
|
||||
osm_path: String,
|
||||
clip: Option<String>,
|
||||
driving_side: map_model::DrivingSide,
|
||||
filter_crosswalks: bool,
|
||||
create_uk_travel_demand_model: bool,
|
||||
opts: RawToMapOptions,
|
||||
@ -57,7 +56,7 @@ pub async fn oneshot(
|
||||
let mut timer = abstutil::Timer::new("oneshot");
|
||||
println!("- Running convert_osm on {}", osm_path);
|
||||
let name = abstutil::basename(&osm_path);
|
||||
let mut options = convert_osm::Options::default_for_side(driving_side);
|
||||
let mut options = convert_osm::Options::default();
|
||||
options.filter_crosswalks = filter_crosswalks;
|
||||
let raw = convert_osm::convert(
|
||||
osm_path,
|
||||
|
@ -21,10 +21,8 @@ pub fn config_for_map(name: &MapName) -> convert_osm::Options {
|
||||
|
||||
convert_osm::Options {
|
||||
map_config: osm2streets::MapConfig {
|
||||
driving_side: match name.city.country.as_ref() {
|
||||
"au" | "gb" | "in" | "jp" | "nz" | "sg" => DrivingSide::Left,
|
||||
_ => DrivingSide::Right,
|
||||
},
|
||||
// osm2streets will set this anyway, it doesn't matter here
|
||||
driving_side: DrivingSide::Right,
|
||||
bikes_can_use_bus_lanes: name.city.country != "pl",
|
||||
inferred_sidewalks: name.city.country != "pl",
|
||||
street_parking_spot_length: if name.city == CityName::new("ca", "montreal") {
|
||||
|
@ -529,15 +529,12 @@ fn chose_city<A: AppLike + 'static>(
|
||||
fn reimport_city<A: AppLike + 'static>(ctx: &mut EventCtx, app: &A) -> Transition<A> {
|
||||
let name = format!("updated_{}", app.map().get_name().as_filename());
|
||||
|
||||
let mut args = vec![
|
||||
let args = vec![
|
||||
crate::tools::find_exe("cli"),
|
||||
"one-step-import".to_string(),
|
||||
"--geojson-path=boundary.json".to_string(),
|
||||
format!("--map-name={}", name),
|
||||
];
|
||||
if app.map().get_config().driving_side == map_model::DrivingSide::Left {
|
||||
args.push("--drive-on-left".to_string());
|
||||
}
|
||||
|
||||
// Write the current map boundary
|
||||
abstio::write_json(
|
||||
|
@ -49,14 +49,6 @@ impl<A: AppLike + 'static> ImportCity<A> {
|
||||
"Copy the JSON text on the right into your clipboard".text_widget(ctx),
|
||||
])
|
||||
.margin_below(16),
|
||||
Toggle::choice(
|
||||
ctx,
|
||||
"left handed driving",
|
||||
"drive on the left",
|
||||
"right",
|
||||
None,
|
||||
false,
|
||||
),
|
||||
Widget::row(vec![
|
||||
"Name the map:".text_widget(ctx).centered_vert(),
|
||||
TextBox::widget(ctx, "new_map_name", generate_new_map_name(), true, 20),
|
||||
@ -121,9 +113,6 @@ impl<A: AppLike + 'static> State<A> for ImportCity<A> {
|
||||
"--geojson-path=boundary.geojson".to_string(),
|
||||
format!("--map-name={}", name),
|
||||
];
|
||||
if self.panel.is_checked("left handed driving") {
|
||||
args.push("--drive-on-left".to_string());
|
||||
}
|
||||
if self.panel.is_checked("source") {
|
||||
args.push("--use-geofabrik".to_string());
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ impl Map {
|
||||
bus_routes_on_roads: MultiMap::new(),
|
||||
gps_bounds: GPSBounds::new(),
|
||||
bounds: Bounds::new(),
|
||||
config: MapConfig::default_for_side(DrivingSide::Right),
|
||||
config: MapConfig::default(),
|
||||
pathfinder: Pathfinder::empty(),
|
||||
pathfinder_dirty: false,
|
||||
routing_params: RoutingParams::default(),
|
||||
|
@ -59,7 +59,7 @@ fn import_map(path: String) -> Map {
|
||||
path,
|
||||
name,
|
||||
clip,
|
||||
convert_osm::Options::default_for_side(map_model::DrivingSide::Right),
|
||||
convert_osm::Options::default(),
|
||||
&mut timer,
|
||||
);
|
||||
Map::create_from_raw(raw, map_model::RawToMapOptions::default(), &mut timer)
|
||||
|
Loading…
Reference in New Issue
Block a user