From 4ac40016fbc382b1c31951f6a6d384b02880c053 Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Sat, 2 Feb 2019 16:28:27 +0100 Subject: [PATCH] Output results as required --- src/main.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0dc5290..322b696 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,6 +42,7 @@ fn main() { // 07:00: Bus ist 15 km entfernt let start_time = NaiveTime::from_hms(7, 0, 0); let bus = Point::new(0.0, -15000.0); + let bus_start = bus; // 30 km/h -> 8.3 m/s let bus_speed = 30.0 / 3.6; // Zeitpunkt basierend auf Wartezeit in Sekunden berechnen @@ -154,12 +155,28 @@ fn main() { states.extend(all); } } - eprintln!("Zeit = {:?}", delay_to_time(best_delay)); let route = best; + eprintln!("Startzeit: {:?}", delay_to_time(best_delay)); + eprintln!("Zielzeit: {:?}", delay_to_time(route.last().unwrap().bus.y() - bus_start.y())); + eprintln!("Treffpunkt: y={:.0}", route.last().unwrap().pos.y()); + let mut length = 0.0; + let mut last = &house; eprintln!("Route:"); for s in &route { - eprintln!("{:.02},{:.02}", s.pos.x(), s.pos.y()); + if s.pos == house { + eprint!("Lisas Haus: ") + } else if s.pos.x() == 0.0 { + eprint!("Treffpunkt: ") + } else { + eprint!("Polygon {:02}: ", polys.iter().position(|p| p.exterior.0.contains(&s.pos.into())).unwrap() + 1); + } + eprintln!("x={:.02} y={:.02}", s.pos.x(), s.pos.y()); + length += last.euclidean_distance(&s.pos); + last = &s.pos; } + eprintln!("Länge: {:.0}m", length); + let seconds = length / (15.0 / 3.6); + eprintln!("Dauer: {:02.0}:{:02.0}", seconds / 60.0, seconds % 60.0); display::dump_route(house, &polys, &route); }