Skip to content

Commit

Permalink
Fix build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Nov 25, 2023
1 parent 9181106 commit e143bc4
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 42 deletions.
20 changes: 2 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[workspace]

resolver = "2"

members = [
"abstio",
"abstutil",
Expand Down
18 changes: 8 additions & 10 deletions apps/ltn/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod filters;
use std::collections::HashMap;

use geom::{Angle, Distance, Pt2D};
use map_model::{AmenityType, ExtraPOIType, FilterType, Map, RestrictionType, Road, TurnType, RoadID};
use map_model::{AmenityType, ExtraPOIType, FilterType, Map, RestrictionType, Road, TurnType};
use widgetry::mapspace::DrawCustomUnzoomedShapes;
use widgetry::{Color, Drawable, EventCtx, GeomBatch, GfxCtx, Line, RewriteColor, Text};

Expand Down Expand Up @@ -79,34 +79,32 @@ pub fn render_bus_routes(ctx: &EventCtx, map: &Map) -> Drawable {
ctx.upload(batch)
}


pub fn render_turn_restrictions(ctx: &EventCtx, map: &Map) -> Drawable {
let mut batch = GeomBatch::new();
for r1 in map.all_roads() {
// TODO Also interpret lane-level? Maybe just check all the generated turns and see what's
// allowed / banned in practice?

// Count the number of turn restrictions at each end of the road
let mut icon_counter = HashMap::from([
(r1.dst_i, 1),
(r1.src_i, 1),
]);
let mut icon_counter = HashMap::from([(r1.dst_i, 1), (r1.src_i, 1)]);

for (restriction, r2) in &r1.turn_restrictions {
// TODO "Invert" OnlyAllowTurns so we can just draw banned things
if *restriction == RestrictionType::BanTurns {
let (t_type, sign_pt, r1_angle, i) = map.get_ban_turn_info(r1, map.get_r(*r2), &icon_counter);
let (t_type, sign_pt, r1_angle, i) =
map.get_ban_turn_info(r1, map.get_r(*r2), &icon_counter);
// add to the counter
icon_counter.entry(i).and_modify(|n| *n+=1);
icon_counter.entry(i).and_modify(|n| *n += 1);
batch.append(draw_turn_restriction_icon(
ctx, t_type, sign_pt, r1, r1_angle,
));
}
}
for (_via, r2) in &r1.complicated_turn_restrictions {
// TODO Show the 'via'? Or just draw the entire shape?
let (t_type, sign_pt, r1_angle, i) = map.get_ban_turn_info(r1, map.get_r(*r2), &icon_counter);
icon_counter.entry(i).and_modify(|n| *n+=1);
let (t_type, sign_pt, r1_angle, i) =
map.get_ban_turn_info(r1, map.get_r(*r2), &icon_counter);
icon_counter.entry(i).and_modify(|n| *n += 1);
batch.append(draw_turn_restriction_icon(
ctx, t_type, sign_pt, r1, r1_angle,
));
Expand Down
4 changes: 2 additions & 2 deletions map_gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ release_s3 = []
abstio = { path = "../abstio" }
abstutil = { path = "../abstutil" }
anyhow = { workspace = true }
built = { version = "0.6.0", optional = true, features=["chrono"] }
built = { version = "0.7.1", optional = true, features=["chrono"] }
chrono = "0.4.24"
colorous = { workspace = true }
contour = { workspace = true }
Expand All @@ -39,4 +39,4 @@ widgetry = { path = "../widgetry" }
fs-err = { workspace = true }

[build-dependencies]
built = "0.6.0"
built = { version = "0.7.1", features=["chrono"] }
12 changes: 7 additions & 5 deletions map_model/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1139,13 +1139,15 @@ impl Map {
ideal_dist_from_intersection = 0.3 * r1.center_pts.length();
}
}

// Adjust according to which end of the road we've measuring from
let dist_from_intersection = if r1.src_i == i { ideal_dist_from_intersection } else { r1.center_pts.length() - ideal_dist_from_intersection };
let dist_from_intersection = if r1.src_i == i {
ideal_dist_from_intersection
} else {
r1.center_pts.length() - ideal_dist_from_intersection
};

let (sign_pt, mut r1_angle) = r1
.center_pts
.must_dist_along(dist_from_intersection);
let (sign_pt, mut r1_angle) = r1.center_pts.must_dist_along(dist_from_intersection);

// Correct the angle, based on whether the vector direction is towards or away from the intersection
// TODO what is the standard way of describing the vector direction (rather than the traffic direction) for roads?
Expand Down
11 changes: 4 additions & 7 deletions tests/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Integration tests

use std::{io::Write, collections::HashMap};
use std::{collections::HashMap, io::Write};

use anyhow::{bail, Result};
use fs_err::File;
Expand Down Expand Up @@ -113,14 +113,11 @@ fn all_turn_info_as_string(map: &Map) -> String {

s.push_str("\n------------\nRestrictions:\n------------\n");
for r1 in map.all_roads() {

let icon_counter = HashMap::from([
(r1.dst_i, 1),
(r1.src_i, 1),
]);
let icon_counter = HashMap::from([(r1.dst_i, 1), (r1.src_i, 1)]);

for (restriction, r2) in &r1.turn_restrictions {
let (t_type, sign_pt, _, i_id) = map.get_ban_turn_info(r1, map.get_r(*r2), &icon_counter);
let (t_type, sign_pt, _, i_id) =
map.get_ban_turn_info(r1, map.get_r(*r2), &icon_counter);
let i = map.get_i(i_id);
s.push_str(&format!(
"Turn from {} into {}, at intersection {:?} is a {:?}, type {:?}, location {}\n",
Expand Down

0 comments on commit e143bc4

Please sign in to comment.