diff --git a/editor/src/mission/dataviz.rs b/editor/src/mission/dataviz.rs index 3ab1bc9cf2..5688cb7f5e 100644 --- a/editor/src/mission/dataviz.rs +++ b/editor/src/mission/dataviz.rs @@ -27,6 +27,7 @@ struct Tract { num_bldgs: usize, num_parking_spots: usize, + total_owned_cars: usize, } impl DataVisualizer { @@ -67,6 +68,10 @@ impl DataVisualizer { "{} parking spots ", prettyprint_usize(tract.num_parking_spots) )); + txt.add_line(format!( + "{} total owned cars", + prettyprint_usize(tract.total_owned_cars) + )); } self.menu.handle_event(ctx, Some(txt)); ctx.canvas.handle_event(ctx.input); @@ -189,6 +194,7 @@ fn clip(popdat: &PopDat, ui: &UI, timer: &mut Timer) -> BTreeMap color: Color::WHITE, num_bldgs, num_parking_spots, + total_owned_cars: tract.total_owned_cars(), }, ); } diff --git a/popdat/src/lib.rs b/popdat/src/lib.rs index 9f0a2dd1cc..5f99787ad1 100644 --- a/popdat/src/lib.rs +++ b/popdat/src/lib.rs @@ -146,3 +146,22 @@ fn group_attribs(mut attribs: BTreeMap) -> BTreeMap usize { + let mut sum = 0; + for (name, est) in &self.household_vehicles { + match name.as_str() { + "1 vehicle avail." => sum += 1 * est.value, + "2 vehicles avail." => sum += 2 * est.value, + "3 vehicles avail." => sum += 3 * est.value, + // Many more than 4 seems unrealistic + "4 or more vehicles avail." => sum += 4 * est.value, + "No vehicle avail." | "Total:" => {} + _ => panic!("Unknown household_vehicles key {}", name), + } + } + sum + } +}