slowly moving away from depending on other_side in Road, and declaring LaneType stuff

This commit is contained in:
Dustin Carlino 2018-06-19 09:03:26 -07:00
parent 6a695740bd
commit ef78902f9a
5 changed files with 48 additions and 17 deletions

View File

@ -12,12 +12,15 @@
- drop events sometimes
- 3D UI sharing the same structure as the 2D one
- svg export some area, for manual mockups
- web version
- easier way to define magic tuneable constants
- and maybe to recalculate fixedish things if they change?
- more advanced road modeling, like https://wiki.openstreetmap.org/wiki/Proposed_features/Street_area
## Conga line idea
- try constructive approach for snake idea

View File

@ -44,7 +44,7 @@ Initial design:
- ideally, get rid of one-wayness and original center points, and plumb along pre-shifted lines
- but due to the polyline problem (affecting both geom center line layer that agents follow, and polygons for drawing), can't do this. encapsulate the messiness at least.
- so, store one way and orig points and index, but have an accessor
- as a compromise, dont interpet OSM points on a one-way road as the center, but as the edge.
- as a compromise, dont interpet OSM points on a one-way road as the center, but as the edge? this is proving hard to do.

View File

@ -27,12 +27,6 @@ impl DrawRoad {
pub fn new(road: &map_model::Road, geom_map: &geom::GeomMap) -> DrawRoad {
let geom_r = geom_map.get_r(road.id);
let use_yellow_center_lines = if let Some(other) = road.other_side {
road.id.0 < other.0
} else {
false
};
let thick_line = if road.other_side.is_some() {
geometry::ThickLine::DrivingDirectionOnly(geom::LANE_THICKNESS)
} else {
@ -42,7 +36,7 @@ impl DrawRoad {
DrawRoad {
id: road.id,
polygons: geometry::thick_multiline(&thick_line, &geom_r.pts),
yellow_center_lines: if use_yellow_center_lines {
yellow_center_lines: if road.use_yellow_center_lines {
geom_r.pts.clone()
} else {
Vec::new()

View File

@ -40,15 +40,9 @@ impl GeomRoad {
pts[0] = Pt2D::from(new_first_pt);
pts[num_pts - 1] = Pt2D::from(new_last_pt);
let use_yellow_center_lines = if let Some(other) = road.other_side {
road.id.0 < other.0
} else {
false
};
let lane_center_shift = if road.other_side.is_none() {
0.0
} else if use_yellow_center_lines {
} else if road.use_yellow_center_lines {
// TODO I think this is unfair to one side, right? If we hover over the yellow line, it
// shouldn't match either lane. Needs to be its own thing, or adjust the bbox.
(LANE_THICKNESS / 2.0) + (BIG_ARROW_THICKNESS / 2.0)

View File

@ -148,19 +148,33 @@ pub struct Map {
intersection_to_roads: HashMap<IntersectionID, Vec<RoadID>>,
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub enum LaneType {
Driving,
Parking,
Sidewalk,
}
#[derive(Debug)]
pub struct Road {
pub id: RoadID,
pub osm_tags: Vec<String>,
pub osm_way_id: i64,
lane_type: LaneType,
// Ideally all of these would just become translated center points immediately, but this is
// hard due to the polyline problem.
// The orientation is implied by the order of these points
pub points: Vec<Pt2D>,
// Should this lane own the drawing of the yellow center lines? For two-way roads, this is
// arbitrarily grouped with one of the lanes. Ideally it would be owned by something else.
pub use_yellow_center_lines: bool,
pub other_side: Option<RoadID>,
//offset: u8,
// All roads are two-way (since even one-way streets have sidewalks on both sides). Offset 0 is
// the centermost lane on each side, then it counts up.
offset: u8,
}
impl PartialEq for Road {
@ -253,9 +267,27 @@ impl Map {
let mut counter = 0;
for r in data.get_roads() {
let oneway = r.get_osm_tags().contains(&String::from("oneway=yes"));
let orig_direction = true;
let reverse_direction = false;
let mut lanes = vec![
(LaneType::Driving, 0, orig_direction),
(LaneType::Parking, 1, orig_direction),
(LaneType::Sidewalk, 2, orig_direction),
];
if oneway {
lanes.push((LaneType::Sidewalk, 0, reverse_direction));
} else {
lanes.extend(vec![
(LaneType::Driving, 0, reverse_direction),
(LaneType::Parking, 1, reverse_direction),
(LaneType::Sidewalk, 2, reverse_direction),
]);
}
// TODO I made a second iter of cloned roads and tried to chain, but couldn't make the
// types work :( so here's this hackier version
let oneway = r.get_osm_tags().contains(&String::from("oneway=yes"));
for &idx_offset in &vec![0, 1] {
if idx_offset == 1 && r.get_osm_tags().contains(&String::from("oneway=yes")) {
continue;
@ -292,6 +324,14 @@ impl Map {
points: pts,
osm_tags: r.get_osm_tags().to_vec(),
osm_way_id: r.get_osm_way_id(),
use_yellow_center_lines: if let Some(other) = other_side {
id.0 < other.0
} else {
false
},
offset: 0,
lane_type: LaneType::Driving,
});
}
}