mirror of
https://github.com/a-b-street/abstreet.git
synced 2025-01-01 10:57:17 +03:00
handle border nodes being bidirectional. also only assign borders during
convert_osm. still disabled... am confused. some hacks to make things work in the meantime.
This commit is contained in:
parent
4dd7dabde5
commit
9ea7493483
@ -64,6 +64,16 @@ impl DrawIntersection {
|
||||
.into_iter()
|
||||
.map(|p| (cs.get_def("border node arrow", Color::PURPLE), p)),
|
||||
);
|
||||
|
||||
// TODO Do this better.
|
||||
if !i.incoming_lanes.is_empty() && i.outgoing_lanes.is_empty() {
|
||||
default_geom.extend(
|
||||
line.reverse()
|
||||
.make_arrow((r.all_lanes().len() as f64) * LANE_THICKNESS / 3.0)
|
||||
.into_iter()
|
||||
.map(|p| (cs.get("border node arrow"), p)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
DrawIntersection {
|
||||
|
@ -248,7 +248,12 @@ impl<S: UIState> GUI<RenderingHints> for UI<S> {
|
||||
fn new_draw(&self, g: &mut GfxCtx, hints: &RenderingHints, screencap: bool) -> Option<String> {
|
||||
let state = self.state.get_state();
|
||||
|
||||
g.clear(state.cs.get_def("true background", Color::BLACK));
|
||||
// TODO Not quite ready yet
|
||||
if false {
|
||||
g.clear(state.cs.get_def("true background", Color::BLACK));
|
||||
} else {
|
||||
g.clear(state.cs.get("map background"));
|
||||
}
|
||||
g.redraw(&state.primary.draw_map.boundary_polygon);
|
||||
|
||||
let mut cache = state.primary.draw_map.agents.borrow_mut();
|
||||
|
@ -128,13 +128,13 @@ pub fn make_half_map(
|
||||
}
|
||||
|
||||
for i in half_map.intersections.iter_mut() {
|
||||
if i.incoming_lanes.is_empty() && i.outgoing_lanes.is_empty() {
|
||||
panic!("{:?} is orphaned!", i);
|
||||
if i.intersection_type == IntersectionType::Border {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Is the intersection a border?
|
||||
if is_border(i, &half_map.lanes) {
|
||||
i.intersection_type = IntersectionType::Border;
|
||||
// TODO Stronger to look for ||
|
||||
if i.incoming_lanes.is_empty() && i.outgoing_lanes.is_empty() {
|
||||
panic!("{:?} is orphaned!", i);
|
||||
}
|
||||
|
||||
for t in make::turns::make_all_turns(i, &half_map.roads, &half_map.lanes) {
|
||||
@ -191,29 +191,3 @@ pub fn make_half_map(
|
||||
|
||||
half_map
|
||||
}
|
||||
|
||||
fn is_border(intersection: &Intersection, lanes: &Vec<Lane>) -> bool {
|
||||
// Raw data said it is.
|
||||
if intersection.intersection_type == IntersectionType::Border {
|
||||
if !intersection.is_dead_end() {
|
||||
panic!(
|
||||
"{:?} isn't a dead-end, but raw data said it's a border node",
|
||||
intersection
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// Bias for driving
|
||||
if !intersection.is_dead_end() {
|
||||
return false;
|
||||
}
|
||||
let has_driving_in = intersection
|
||||
.incoming_lanes
|
||||
.iter()
|
||||
.any(|l| lanes[l.0].is_driving());
|
||||
let has_driving_out = intersection
|
||||
.outgoing_lanes
|
||||
.iter()
|
||||
.any(|l| lanes[l.0].is_driving());
|
||||
has_driving_in != has_driving_out
|
||||
}
|
||||
|
@ -11,9 +11,7 @@ use std::iter;
|
||||
// TODO Add proper warnings when the geometry is too small to handle.
|
||||
|
||||
pub fn make_all_turns(i: &Intersection, roads: &Vec<Road>, lanes: &Vec<Lane>) -> Vec<Turn> {
|
||||
if i.intersection_type == IntersectionType::Border {
|
||||
return Vec::new();
|
||||
}
|
||||
assert!(i.intersection_type != IntersectionType::Border);
|
||||
|
||||
let mut turns: Vec<Turn> = Vec::new();
|
||||
turns.extend(make_vehicle_turns(i, roads, lanes));
|
||||
|
@ -32,10 +32,10 @@ pub struct Map {
|
||||
areas: Vec<Area>,
|
||||
boundary_polygon: Polygon,
|
||||
|
||||
// Note that border nodes belong in neither!
|
||||
stop_signs: BTreeMap<IntersectionID, ControlStopSign>,
|
||||
traffic_signals: BTreeMap<IntersectionID, ControlTrafficSignal>,
|
||||
|
||||
// Note that border nodes belong in neither!
|
||||
gps_bounds: GPSBounds,
|
||||
bounds: Bounds,
|
||||
|
||||
|
@ -111,7 +111,6 @@ impl Road {
|
||||
pub struct Intersection {
|
||||
pub point: LonLat,
|
||||
pub elevation: Distance,
|
||||
// A raw Intersection can be forced into being a Border.
|
||||
pub intersection_type: IntersectionType,
|
||||
pub label: Option<String>,
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ impl ControlTrafficSignal {
|
||||
error!("{} has no turns", intersection);
|
||||
return Some(ControlTrafficSignal {
|
||||
id: intersection,
|
||||
cycles: Vec::new(),
|
||||
cycles: vec![Cycle::new(intersection, 0)],
|
||||
changed: false,
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user