mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-24 23:15:24 +03:00
add a signal policy for half signals, inadvertently brought in by fe94357332
. update a signal in south seattle.
will regenerate in the next change
This commit is contained in:
parent
adbbc8764a
commit
dd3f3d14ab
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -2829,7 +2829,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "seattle_traffic_signals"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/dabreegster/seattle_traffic_signals#c110e0dfb330a3fd9dcfbb8df45403adf0d10c8e"
|
||||
source = "git+https://github.com/dabreegster/seattle_traffic_signals#9a3a77da15a7eefacc5553579c0b80b7eeae2ff4"
|
||||
dependencies = [
|
||||
"include_dir 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
ControlTrafficSignal, IntersectionCluster, IntersectionID, Map, Phase, RoadID, TurnGroup,
|
||||
TurnGroupID, TurnPriority, TurnType,
|
||||
ControlTrafficSignal, IntersectionCluster, IntersectionID, Map, Phase, PhaseType, RoadID,
|
||||
TurnGroup, TurnGroupID, TurnPriority, TurnType,
|
||||
};
|
||||
use abstutil::Timer;
|
||||
use geom::Duration;
|
||||
@ -42,6 +42,9 @@ pub fn get_possible_policies(
|
||||
if let Some(ts) = four_way_four_phase(map, id) {
|
||||
results.push(("four-phase".to_string(), ts));
|
||||
}
|
||||
if let Some(ts) = half_signal(map, id) {
|
||||
results.push(("half signal (2 roads with crosswalk)".to_string(), ts));
|
||||
}
|
||||
if let Some(ts) = degenerate(map, id) {
|
||||
results.push(("degenerate (2 roads)".to_string(), ts));
|
||||
}
|
||||
@ -124,6 +127,33 @@ fn degenerate(map: &Map, i: IntersectionID) -> Option<ControlTrafficSignal> {
|
||||
ts.validate().ok()
|
||||
}
|
||||
|
||||
fn half_signal(map: &Map, i: IntersectionID) -> Option<ControlTrafficSignal> {
|
||||
if map.get_i(i).roads.len() != 2 {
|
||||
return None;
|
||||
}
|
||||
|
||||
let turn_groups = TurnGroup::for_i(i, map);
|
||||
let mut vehicle_phase = Phase::new();
|
||||
let mut ped_phase = Phase::new();
|
||||
for (id, group) in &turn_groups {
|
||||
if id.crosswalk {
|
||||
ped_phase.edit_group(group, TurnPriority::Protected);
|
||||
} else {
|
||||
vehicle_phase.edit_group(group, TurnPriority::Protected);
|
||||
}
|
||||
}
|
||||
vehicle_phase.phase_type = PhaseType::Fixed(Duration::minutes(1));
|
||||
ped_phase.phase_type = PhaseType::Fixed(Duration::seconds(10.0));
|
||||
|
||||
let ts = ControlTrafficSignal {
|
||||
id: i,
|
||||
phases: vec![vehicle_phase, ped_phase],
|
||||
offset: Duration::ZERO,
|
||||
turn_groups,
|
||||
};
|
||||
ts.validate().ok()
|
||||
}
|
||||
|
||||
fn three_way(map: &Map, i: IntersectionID) -> Option<ControlTrafficSignal> {
|
||||
if map.get_i(i).roads.len() != 3 {
|
||||
return None;
|
||||
|
Loading…
Reference in New Issue
Block a user