populate turns from multiple lanes to a single right/left turn

This commit is contained in:
Dustin Carlino 2019-02-23 11:11:57 -08:00
parent ce019ed08d
commit 5bd840d296
2 changed files with 32 additions and 14 deletions

View File

@ -14,19 +14,19 @@ b7ba74eaab17a7f58cb9ef23735ff8ce ../data/screenshots/pending_montlake/06x02.png
7e7e8c9ebb7074a24477f476f464e68f ../data/screenshots/pending_montlake/02x03_i66.png
04f53200a16a95b4bbb962ea9f6f9028 ../data/screenshots/pending_montlake/03x03.png
b49908a81b09fec864d9260fc73e0e7e ../data/screenshots/pending_montlake/04x03_i6.png
b5986c8b463d42b6b1fb60ff3caab8fa ../data/screenshots/pending_montlake/05x03_i4.png
941352de7111c94f768fb551ee4c2d2a ../data/screenshots/pending_montlake/05x03_i4.png
6675ed768785b92d957d13d906ff529d ../data/screenshots/pending_montlake/06x03_i196.png
59bdc0c1b97c83647c576c43982ffe63 ../data/screenshots/pending_montlake/01x04_i368.png
bdc8cf5cdbfcf3a68ac26087c80788fd ../data/screenshots/pending_montlake/02x04_i51.png
df78fc7e827b6252837a9088326d3513 ../data/screenshots/pending_montlake/03x04.png
55ec583123bdf0be6a2e5d15dc286cf7 ../data/screenshots/pending_montlake/04x04_i147.png
fac469ed8918fc45a93876ae326d691f ../data/screenshots/pending_montlake/05x04_i46.png
dad12152eec1da7443ef86fcfb5a9263 ../data/screenshots/pending_montlake/05x04_i46.png
feef555fe7dad68d634b1ce029882fa4 ../data/screenshots/pending_montlake/06x04_i49.png
cda3845cff17bc83d39502b07e1ac9f4 ../data/screenshots/pending_montlake/01x05_i113.png
0761b6ccefa0eea8a0c801d443a5cd29 ../data/screenshots/pending_montlake/02x05_i14.png
c7f0aae0a525a1950526365fb06a8ea5 ../data/screenshots/pending_montlake/03x05_i39.png
4f687cde233a27002c4bd69dd08b308f ../data/screenshots/pending_montlake/04x05_i10.png
9e6effcb2ac912cc99deeb1174b13376 ../data/screenshots/pending_montlake/05x05_i180.png
6c7369905ac264eab54a2a2dfca4b628 ../data/screenshots/pending_montlake/05x05_i180.png
e68189953e4d79cdc957dffa0f8c90e6 ../data/screenshots/pending_montlake/06x05_i21.png
36b87a6375d5b2474aea1bc3016068c7 ../data/screenshots/pending_montlake/01x06_i22.png
dcadf47c50bdb1bcb65ec0827afd2cf2 ../data/screenshots/pending_montlake/02x06_i8.png
@ -42,12 +42,12 @@ c4d07a30a8ee84083d04df0c9dee4812 ../data/screenshots/pending_montlake/02x07_i8.
a46750d073b83cd61c5f699e07728354 ../data/screenshots/pending_montlake/06x07_i33.png
0f34f7e2aeec5643da7ee02b3e031be5 ../data/screenshots/pending_montlake/01x08_i18.png
e02fb00a29359e87baf65b487c1e305e ../data/screenshots/pending_montlake/02x08_i19.png
6530d1d895de78090f7ff8cd04e43f0e ../data/screenshots/pending_montlake/03x08_i75.png
408b68dc1ddda25683202c7528c44b76 ../data/screenshots/pending_montlake/03x08_i75.png
e23374a63d3ac911a3c1a4abe6a91962 ../data/screenshots/pending_montlake/04x08_i16.png
481e5f69f5059ee2543f04cb9fcf58b1 ../data/screenshots/pending_montlake/05x08_i34.png
aa38ae16ecb33958293653f314528aed ../data/screenshots/pending_montlake/06x08_i1.png
56173560c961cc1d8a848284e01b749f ../data/screenshots/pending_montlake/01x09_i124.png
f3122db1a75e488aafd640cb93a3810b ../data/screenshots/pending_montlake/02x09_i125.png
ed24ea30b7dafc9b3e96dd71abab7574 ../data/screenshots/pending_montlake/02x09_i125.png
22f901145799484124f1a1442c956d22 ../data/screenshots/pending_montlake/03x09_i40.png
84e14d108a039af941236c0af09de93e ../data/screenshots/pending_montlake/04x09_i30.png
d727dc5108773e7fe7211b5bfa0215c2 ../data/screenshots/pending_montlake/05x09_i24.png

View File

@ -99,6 +99,9 @@ fn make_vehicle_turns(
continue;
}
let mut maybe_add_turns = Vec::new();
let mut all_incoming_lanes_covered = false;
for r2 in &roads {
if r1.id == r2.id {
continue;
@ -119,6 +122,7 @@ fn make_vehicle_turns(
// Use an arbitrary lane from each road to get the angle between r1 and r2.
let angle1 = lanes[incoming[0].0].last_line().angle();
let angle2 = lanes[outgoing[0].0].first_line().angle();
match TurnType::from_angles(angle1, angle2) {
TurnType::Straight => {
// Cartesian product
@ -127,25 +131,39 @@ fn make_vehicle_turns(
result.push(make_vehicle_turn(lanes, i.id, *l1, *l2));
}
}
all_incoming_lanes_covered = true;
}
TurnType::Right => {
for l2 in &outgoing {
result.push(make_vehicle_turn(
lanes,
i.id,
*incoming.last().unwrap(),
*l2,
));
for (idx, l1) in incoming.iter().enumerate() {
for l2 in &outgoing {
let turn = make_vehicle_turn(lanes, i.id, *l1, *l2);
if idx == incoming.len() - 1 {
result.push(turn);
} else {
maybe_add_turns.push(turn);
}
}
}
}
TurnType::Left => {
for l2 in outgoing {
result.push(make_vehicle_turn(lanes, i.id, incoming[0], l2));
for (idx, l1) in incoming.iter().enumerate() {
for l2 in &outgoing {
let turn = make_vehicle_turn(lanes, i.id, *l1, *l2);
if idx == 0 {
result.push(turn);
} else {
maybe_add_turns.push(turn);
}
}
}
}
_ => unreachable!(),
};
}
if !all_incoming_lanes_covered {
result.extend(maybe_add_turns);
}
}
}