Optionally keep building OSM tags. Display in info panels and the new viewer, when present.

Don't keep the tags by default. File size increase from the empty map is
negligible.
This commit is contained in:
Dustin Carlino 2020-10-24 14:19:22 -07:00
parent ad23da1f6c
commit 34b41a909e
12 changed files with 98 additions and 37 deletions

View File

@ -240,6 +240,10 @@ impl Tags {
self.0.remove(k)
}
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
// TODO Really just iter()
pub fn inner(&self) -> &BTreeMap<String, String> {
&self.0

View File

@ -397,56 +397,56 @@
"dropbox_url": "https://www.dropbox.com/s/ibvdbbdjdi233mr/seattle.bin.zip?dl=0"
},
"data/system/maps/ballard.bin": {
"checksum": "cf1ee807cf67453ce0d92fd7ae2353a0",
"dropbox_url": "https://www.dropbox.com/s/xxdgxmjg7h3bine/ballard.bin.zip?dl=0"
"checksum": "f53ea69b1b8c62d611795d748e1e67ca",
"dropbox_url": "https://www.dropbox.com/s/gkhrsi1adi905lp/ballard.bin.zip?dl=0"
},
"data/system/maps/berlin_center.bin": {
"checksum": "0e1e361ee45589810b44b7d69f08ebd5",
"dropbox_url": "https://www.dropbox.com/s/ku1n7i6e3mv1tu5/berlin_center.bin.zip?dl=0"
"checksum": "e9474395f8a4f5f13941593745c64986",
"dropbox_url": "https://www.dropbox.com/s/93chwc62k74n8u3/berlin_center.bin.zip?dl=0"
},
"data/system/maps/downtown.bin": {
"checksum": "dfb1e44a802fa0476c5a9388bab19e01",
"dropbox_url": "https://www.dropbox.com/s/ko3le915rbkso2o/downtown.bin.zip?dl=0"
"checksum": "bb6cc3bb5f255e6b86bf0086051be4b3",
"dropbox_url": "https://www.dropbox.com/s/mv0h91a6slgbihd/downtown.bin.zip?dl=0"
},
"data/system/maps/huge_seattle.bin": {
"checksum": "34c0f7b5e098f30a50eea2709c80e251",
"dropbox_url": "https://www.dropbox.com/s/942dw52tw2kobr0/huge_seattle.bin.zip?dl=0"
"checksum": "b324d48a02b46251f73e32f88bfd8266",
"dropbox_url": "https://www.dropbox.com/s/ltvvev9gm0radpi/huge_seattle.bin.zip?dl=0"
},
"data/system/maps/krakow_center.bin": {
"checksum": "4d883a4e9bf320746989dbcf8c3ac1c8",
"dropbox_url": "https://www.dropbox.com/s/cc0o6xlmqidexvg/krakow_center.bin.zip?dl=0"
"checksum": "67f1d4a270a5b20daad66695deb343cf",
"dropbox_url": "https://www.dropbox.com/s/r0048aj3cjkgupt/krakow_center.bin.zip?dl=0"
},
"data/system/maps/lakeslice.bin": {
"checksum": "54830adc049dc3438d6a68c8191510e4",
"dropbox_url": "https://www.dropbox.com/s/hmb226uzr9hewqz/lakeslice.bin.zip?dl=0"
"checksum": "54942cf869156b4967929e099d502980",
"dropbox_url": "https://www.dropbox.com/s/en5g7zzv6ynv4zu/lakeslice.bin.zip?dl=0"
},
"data/system/maps/montlake.bin": {
"checksum": "6cdf3d134bc3714ca2b9b536a7b11517",
"dropbox_url": "https://www.dropbox.com/s/3sq35evuakzr7oj/montlake.bin.zip?dl=0"
"checksum": "b96bd0f0116b52e9a091f108c1113230",
"dropbox_url": "https://www.dropbox.com/s/7r7ivpxs1kiea4o/montlake.bin.zip?dl=0"
},
"data/system/maps/south_seattle.bin": {
"checksum": "a789ebb3f6d55e98069acad329c167a5",
"dropbox_url": "https://www.dropbox.com/s/2y1qqa7sxekrpwa/south_seattle.bin.zip?dl=0"
"checksum": "9b008200ff3eb1270a96c0af4f7fa10f",
"dropbox_url": "https://www.dropbox.com/s/5l2z7xd57visyqf/south_seattle.bin.zip?dl=0"
},
"data/system/maps/southbank.bin": {
"checksum": "7aa6c94501fd745cbe9122702d46ff0c",
"dropbox_url": "https://www.dropbox.com/s/67zc7x6gdyqtomg/southbank.bin.zip?dl=0"
"checksum": "8f83d037ab04bcfdfcb96a0fb2d3ccf7",
"dropbox_url": "https://www.dropbox.com/s/ldsydqidids6fiz/southbank.bin.zip?dl=0"
},
"data/system/maps/tel_aviv.bin": {
"checksum": "839283d1d221db99227645a462f6dc68",
"dropbox_url": "https://www.dropbox.com/s/sz1xf73f914twz5/tel_aviv.bin.zip?dl=0"
"checksum": "d619cfb34bbd92da5e560d62992cf4f5",
"dropbox_url": "https://www.dropbox.com/s/khnpq20pq3qapyo/tel_aviv.bin.zip?dl=0"
},
"data/system/maps/udistrict.bin": {
"checksum": "a547d5d8694371c2c6f9664d9de3f4ac",
"dropbox_url": "https://www.dropbox.com/s/283elifjihv6289/udistrict.bin.zip?dl=0"
"checksum": "c23ccee90f71ae28e0598f9397c7261f",
"dropbox_url": "https://www.dropbox.com/s/zlx8wq2h10pgkaa/udistrict.bin.zip?dl=0"
},
"data/system/maps/west_seattle.bin": {
"checksum": "e867cc142ecf22d2dbd888a1cb76fd41",
"dropbox_url": "https://www.dropbox.com/s/ftqt1adtkd0vhdy/west_seattle.bin.zip?dl=0"
"checksum": "59c42bf75491ef4613762e1305d6d487",
"dropbox_url": "https://www.dropbox.com/s/5mdf06v9kajj4mv/west_seattle.bin.zip?dl=0"
},
"data/system/maps/xian.bin": {
"checksum": "35b50a1a8d33101c55947e4d5ee8985d",
"dropbox_url": "https://www.dropbox.com/s/ydl6tfzt2k60to5/xian.bin.zip?dl=0"
"checksum": "20944e89d1802ea9d6074a6c7ff184cc",
"dropbox_url": "https://www.dropbox.com/s/7bx35jcq5oz2aix/xian.bin.zip?dl=0"
},
"data/system/prebaked_results/lakeslice/weekday.bin": {
"checksum": "c6e5e318341ef37ae6139bb0d5596e53",

View File

@ -161,6 +161,22 @@ impl Viewer {
}
}
col.push(txt.draw(ctx));
if !b.osm_tags.is_empty() {
for (k, v) in b.osm_tags.inner() {
if k.starts_with("abst:") {
continue;
}
col.push(Widget::row(vec![
Btn::plaintext(k).build(
ctx,
format!("open https://wiki.openstreetmap.org/wiki/Key:{}", k),
None,
),
Line(v).draw(ctx).align_right(),
]));
}
}
}
Some(ID::ParkingLot(pl)) => {
let pl = app.primary.map.get_pl(pl);

View File

@ -105,6 +105,18 @@ pub fn info(ctx: &mut EventCtx, app: &App, details: &mut Details, id: BuildingID
if app.opts.dev {
rows.push(Btn::text_bg1("Open OSM").build(ctx, format!("open {}", b.orig_id), None));
if !b.osm_tags.is_empty() {
rows.push("Raw OpenStreetMap data".draw_text(ctx));
rows.extend(make_table(
ctx,
b.osm_tags
.inner()
.iter()
.map(|(k, v)| (k, v.to_string()))
.collect(),
));
}
}
rows

View File

@ -23,6 +23,7 @@ struct Job {
scenario_everyone: bool,
skip_ch: bool,
keep_bldg_tags: bool,
only_map: Option<String>,
@ -46,6 +47,8 @@ fn main() {
// Skip the most expensive step of --map, building contraction hierarchies. The simulation
// will use a slower method to pathfind.
skip_ch: args.enabled("--skip_ch"),
// Preserve OSM tags for buildings, increasing the file size.
keep_bldg_tags: args.enabled("--keep_bldg_tags"),
// Only process one map. If not specified, process all maps defined by clipping polygons in
// data/input/$city/polygons/.
@ -87,6 +90,7 @@ fn main() {
job.oneshot_clip,
!job.oneshot_drive_on_left,
!job.skip_ch,
job.keep_bldg_tags,
);
return;
}
@ -137,7 +141,7 @@ fn main() {
}
let mut maybe_map = if job.raw_to_map {
let mut map = utils::raw_to_map(&name, !job.skip_ch, &mut timer);
let mut map = utils::raw_to_map(&name, !job.skip_ch, job.keep_bldg_tags, &mut timer);
// Another strange step in the pipeline.
if name == "berlin_center" {
@ -197,7 +201,13 @@ fn main() {
}
}
fn oneshot(osm_path: String, clip: Option<String>, drive_on_right: bool, build_ch: bool) {
fn oneshot(
osm_path: String,
clip: Option<String>,
drive_on_right: bool,
build_ch: bool,
keep_bldg_tags: bool,
) {
let mut timer = abstutil::Timer::new("oneshot");
println!("- Running convert_osm on {}", osm_path);
let name = abstutil::basename(&osm_path);
@ -227,7 +237,7 @@ fn oneshot(osm_path: String, clip: Option<String>, drive_on_right: bool, build_c
);
// Often helpful to save intermediate representation in case user wants to load into map_editor
raw.save();
let map = map_model::Map::create_from_raw(raw, build_ch, &mut timer);
let map = map_model::Map::create_from_raw(raw, build_ch, keep_bldg_tags, &mut timer);
timer.start("save map");
map.save();
timer.stop("save map");

View File

@ -128,7 +128,7 @@ pub fn ensure_popdat_exists(
let huge_map = if abstutil::file_exists(abstutil::path_map("huge_seattle")) {
map_model::Map::new(abstutil::path_map("huge_seattle"), timer)
} else {
crate::utils::raw_to_map("huge_seattle", true, timer)
crate::utils::raw_to_map("huge_seattle", true, false, timer)
};
(crate::soundcast::import_data(&huge_map, timer), huge_map)

View File

@ -132,10 +132,15 @@ fn run(cmd: &mut Command) {
}
// Converts a RawMap to a Map.
pub fn raw_to_map(name: &str, build_ch: bool, timer: &mut Timer) -> map_model::Map {
pub fn raw_to_map(
name: &str,
build_ch: bool,
keep_bldg_tags: bool,
timer: &mut Timer,
) -> map_model::Map {
timer.start(format!("Raw->Map for {}", name));
let raw: map_model::raw::RawMap = abstutil::read_binary(abstutil::path_raw_map(name), timer);
let map = map_model::Map::create_from_raw(raw, build_ch, timer);
let map = map_model::Map::create_from_raw(raw, build_ch, keep_bldg_tags, timer);
timer.start("save map");
map.save();
timer.stop("save map");

View File

@ -16,6 +16,7 @@ use crate::{
pub fn make_all_buildings(
input: &BTreeMap<osm::OsmID, RawBuilding>,
map: &Map,
keep_bldg_tags: bool,
timer: &mut Timer,
) -> Vec<Building> {
timer.start("convert buildings");
@ -94,6 +95,11 @@ pub fn make_all_buildings(
b.osm_tags.is("building", "parking") || b.osm_tags.is("amenity", "parking"),
)
},
osm_tags: if keep_bldg_tags {
b.osm_tags.clone()
} else {
Tags::new(BTreeMap::new())
},
sidewalk_pos: *sidewalk_pos,
driveway_geom: sidewalk_line.to_polyline(),

View File

@ -25,7 +25,12 @@ pub mod turns;
mod walking_turns;
impl Map {
pub fn create_from_raw(mut raw: RawMap, build_ch: bool, timer: &mut Timer) -> Map {
pub fn create_from_raw(
mut raw: RawMap,
build_ch: bool,
keep_bldg_tags: bool,
timer: &mut Timer,
) -> Map {
// Better to defer this and see RawMaps with more debug info in map_editor
remove_disconnected::remove_disconnected_roads(&mut raw, timer);
@ -199,7 +204,8 @@ impl Map {
.map(|x| x.ends_with("_link"))
.unwrap_or(false)
|| road.osm_tags.is_any("railway", vec!["rail", "light_rail"])
|| road.osm_tags.is("junction", "roundabout"))
|| road.osm_tags.is("junction", "roundabout")
|| road.osm_tags.is("highway", "service"))
{
timer.warn(format!(
"{} has no name. Tags: {:?}",
@ -267,7 +273,7 @@ impl Map {
}
timer.stop("find blackholes");
map.buildings = buildings::make_all_buildings(&raw.buildings, &map, timer);
map.buildings = buildings::make_all_buildings(&raw.buildings, &map, keep_bldg_tags, timer);
map.parking_lots = parking_lots::make_all_parking_lots(
&raw.parking_lots,

View File

@ -101,7 +101,7 @@ impl Map {
}
let raw: RawMap = abstutil::read_binary(path, timer);
Map::create_from_raw(raw, true, timer)
Map::create_from_raw(raw, true, false, timer)
}
/// If you have to deserialize a `Map` directly, call this after. Prefer using `Map::new`

View File

@ -43,6 +43,8 @@ pub struct Building {
pub amenities: BTreeSet<(NamePerLanguage, String)>,
pub bldg_type: BuildingType,
pub parking: OffstreetParking,
/// Depending on options while importing, these might be empty, to save file space.
pub osm_tags: Tags,
/// The building's connection for pedestrians is immutable. For cars and bikes, it can change
/// based on map edits, so don't cache it.

View File

@ -42,7 +42,7 @@ fn import_map(path: String) -> Map {
},
&mut timer,
);
let map = Map::create_from_raw(raw, true, &mut timer);
let map = Map::create_from_raw(raw, true, true, &mut timer);
map
}