Skip to content

Commit

Permalink
A fresh attempt at bringing in cycleways for #330. Just interpret them
Browse files Browse the repository at this point in the history
as two lane bike-only lanes, for now -- no pedestrians.

- Include the ways, turn them into lanes
- Special unzoomed rendering
  • Loading branch information
dabreegster committed Sep 16, 2020
1 parent 3dcdb9e commit 1f6663d
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 5 deletions.
14 changes: 9 additions & 5 deletions convert_osm/src/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ pub fn extract_osm(map: &mut RawMap, opts: &Options, timer: &mut Timer) -> OsmEx
points: map.gps_bounds.convert_back(&way.pts),
attributes: way.tags.inner().clone(),
});
} else if way
.tags
.is_any(osm::HIGHWAY, vec!["cycleway", "footway", "path"])
{
} else if way.tags.is_any(osm::HIGHWAY, vec!["footway", "path"]) {
extra_footways.shapes.push(ExtraShape {
points: map.gps_bounds.convert_back(&way.pts),
attributes: way.tags.inner().clone(),
Expand Down Expand Up @@ -401,6 +398,8 @@ fn is_road(tags: &mut Tags, opts: &Options) -> bool {
};

if !vec![
"cycleway",
"footway",
"living_street",
"motorway",
"motorway_link",
Expand All @@ -427,6 +426,11 @@ fn is_road(tags: &mut Tags, opts: &Options) -> bool {
return false;
}

// Only footways that connect cycleways.
if highway == "footway" && !tags.is("bicycle", "yes") {
return false;
}

// Not sure what this means, found in Seoul.
if tags.is("lanes", "0") {
return false;
Expand Down Expand Up @@ -454,7 +458,7 @@ fn is_road(tags: &mut Tags, opts: &Options) -> bool {
if tags.is_any(osm::HIGHWAY, vec!["motorway", "motorway_link"])
|| tags.is("junction", "roundabout")
|| tags.is("foot", "no")
|| tags.is(osm::HIGHWAY, "service")
|| tags.is_any(osm::HIGHWAY, vec!["cycleway", "service"])
{
tags.insert(osm::SIDEWALK, "none");
} else if tags.is("oneway", "yes") {
Expand Down
2 changes: 2 additions & 0 deletions game/src/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ pub struct ColorScheme {
pub unzoomed_highway: Color,
pub unzoomed_arterial: Color,
pub unzoomed_residential: Color,
pub unzoomed_trail: Color,

// Intersections
pub normal_intersection: Color,
Expand Down Expand Up @@ -168,6 +169,7 @@ impl ColorScheme {
unzoomed_highway: Color::rgb(232, 146, 162),
unzoomed_arterial: Color::rgb(255, 199, 62),
unzoomed_residential: Color::WHITE,
unzoomed_trail: Color::rgb(15, 125, 75),

// Intersections
normal_intersection: Color::grey(0.2),
Expand Down
2 changes: 2 additions & 0 deletions game/src/render/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ impl DrawMap {
cs.light_rail_track
} else if r.is_private() {
cs.private_road
} else if r.is_cyclepath() {
cs.unzoomed_trail
} else {
rank_to_color(cs, r.get_rank())
},
Expand Down
43 changes: 43 additions & 0 deletions map_model/src/make/initial/lane_specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ pub fn get_lane_specs_ltr(tags: &Tags, driving_side: DrivingSide) -> Vec<LaneSpe
if tags.is_any("railway", vec!["light_rail", "rail"]) {
return vec![fwd(LaneType::LightRail)];
}
if tags.is(osm::HIGHWAY, "cycleway")
|| (tags.is(osm::HIGHWAY, "footway") && tags.is("bicycle", "yes"))
{
let half_width = |mut spec: LaneSpec| {
spec.width = spec.width / 2.0;
spec
};
return assemble_ltr(
vec![half_width(fwd(LaneType::Biking))],
if tags.is("oneway", "yes") {
vec![]
} else {
vec![half_width(back(LaneType::Biking))]
},
driving_side,
);
}
if tags.is(osm::HIGHWAY, "footway") {
return vec![fwd(LaneType::Sidewalk)];
}
Expand Down Expand Up @@ -416,6 +433,32 @@ mod tests {
"sdd",
"^^^",
),
(
"https://www.openstreetmap.org/way/663360444",
vec!["highway=cycleway", "foot=yes", "oneway=no", "segregated=no"],
DrivingSide::Right,
"bb",
"v^",
),
(
"https://www.openstreetmap.org/way/835195089",
vec!["highway=cycleway", "oneway=yes"],
DrivingSide::Right,
"b",
"^",
),
(
"https://www.openstreetmap.org/way/663360436",
vec![
"highway=footway",
"bicycle=yes",
"oneway=no",
"segregated=no",
],
DrivingSide::Right,
"bb",
"v^",
),
] {
let actual = get_lane_specs_ltr(&tags(input.clone()), driving_side);
let actual_lt = actual
Expand Down
5 changes: 5 additions & 0 deletions map_model/src/objects/road.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,11 @@ impl Road {
self.lanes_ltr().len() == 1 && self.lanes_ltr()[0].2 == LaneType::Sidewalk
}

pub fn is_cyclepath(&self) -> bool {
let lanes = self.lanes_ltr();
lanes.len() == 2 && lanes[0].2 == LaneType::Biking && lanes[1].2 == LaneType::Biking
}

pub fn common_endpt(&self, other: &Road) -> IntersectionID {
if self.src_i == other.src_i || self.src_i == other.dst_i {
self.src_i
Expand Down

0 comments on commit 1f6663d

Please sign in to comment.