Skip to content

Commit

Permalink
Initially cutover to osm2lanes
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Apr 27, 2022
1 parent bd5d93b commit 8a9893f
Show file tree
Hide file tree
Showing 6 changed files with 300 additions and 600 deletions.
34 changes: 34 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions abstutil/src/collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ impl Tags {
pub fn contains_key(&self, k: &str) -> bool {
self.0.contains_key(k)
}
pub fn has_any(&self, keys: Vec<&str>) -> bool {
keys.into_iter().any(|key| self.contains_key(key))
}

pub fn is(&self, k: &str, v: &str) -> bool {
self.0.get(k) == Some(&v.to_string())
Expand Down
51 changes: 5 additions & 46 deletions convert_osm/src/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use abstutil::{Tags, Timer};
use geom::{Distance, FindClosest, HashablePt2D, Polygon, Pt2D, Ring};
use kml::{ExtraShape, ExtraShapes};
use raw_map::{
osm, Amenity, AreaType, Direction, DrivingSide, NamePerLanguage, RawArea, RawBuilding, RawMap,
osm, Amenity, AreaType, Direction, NamePerLanguage, RawArea, RawBuilding, RawMap,
RawParkingLot, RawRoad, RestrictionType,
};

Expand Down Expand Up @@ -445,6 +445,7 @@ fn is_road(tags: &mut Tags, opts: &Options, name: &MapName) -> bool {
}

// It's a road! Now fill in some possibly missing data.
// TODO Stop doing this entirely?

// If there's no parking data in OSM already, then assume no parking and mark that it's
// inferred.
Expand All @@ -457,51 +458,9 @@ fn is_road(tags: &mut Tags, opts: &Options, name: &MapName) -> bool {
tags.insert(osm::PARKING_BOTH, "no_parking");
tags.insert(osm::INFERRED_PARKING, "true");
}

// If there's no sidewalk data in OSM already, then make an assumption and mark that
// it's inferred.
if !tags.contains_key(osm::SIDEWALK) && opts.map_config.inferred_sidewalks {
tags.insert(osm::INFERRED_SIDEWALKS, "true");

if tags.contains_key("sidewalk:left") || tags.contains_key("sidewalk:right") {
// Attempt to mangle
// https://wiki.openstreetmap.org/wiki/Key:sidewalk#Separately_mapped_sidewalks_on_only_one_side
// into left/right/both. We have to make assumptions for missing values.
let right = !tags.is("sidewalk:right", "no");
let left = !tags.is("sidewalk:left", "no");
let value = match (right, left) {
(true, true) => "both",
(true, false) => "right",
(false, true) => "left",
(false, false) => "none",
};
tags.insert(osm::SIDEWALK, value);
} else if tags.is_any(osm::HIGHWAY, vec!["motorway", "motorway_link"])
|| tags.is_any("junction", vec!["intersection", "roundabout"])
|| tags.is("foot", "no")
|| tags.is(osm::HIGHWAY, "service")
// TODO For now, not attempting shared walking/biking paths.
|| tags.is_any(osm::HIGHWAY, vec!["cycleway", "pedestrian", "track"])
{
tags.insert(osm::SIDEWALK, "none");
} else if tags.is("oneway", "yes") {
if opts.map_config.driving_side == DrivingSide::Right {
tags.insert(osm::SIDEWALK, "right");
} else {
tags.insert(osm::SIDEWALK, "left");
}
if tags.is_any(osm::HIGHWAY, vec!["residential", "living_street"])
&& !tags.is("dual_carriageway", "yes")
{
tags.insert(osm::SIDEWALK, "both");
}
// Hack for Geneva, which maps sidewalks as separate ways
if name.city == CityName::new("ch", "geneva") {
tags.insert(osm::SIDEWALK, "both");
}
} else {
tags.insert(osm::SIDEWALK, "both");
}
// Hack for Geneva, which maps sidewalks as separate ways
if !tags.contains_key(osm::SIDEWALK) && name.city == CityName::new("ch", "geneva") {
tags.insert(osm::SIDEWALK, "both");
}

true
Expand Down
1 change: 1 addition & 0 deletions raw_map/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ geojson = { version = "0.22.0", features = ["geo-types"] }
geom = { path = "../geom" }
kml = { path = "../kml" }
log = "0.4.14"
osm2lanes = { git = "https://github.com/a-b-street/osm2lanes" }
petgraph = { version = "0.6.0" }
serde = "1.0.123"
serde_json = "1.0.61"
Expand Down
Loading

0 comments on commit 8a9893f

Please sign in to comment.