a-b-street / osm2streets

Convert OSM to street networks with detailed geometry
https://a-b-street.github.io/osm2streets
Apache License 2.0
94 stars 8 forks source link

Use lane width tags from OSM #222

Closed dabreegster closed 6 months ago

dabreegster commented 1 year ago

sidewalk:{left,right}:width as one example, probably others. Add tests for these.

dabreegster commented 1 year ago

More context here: the code in https://github.com/a-b-street/osm2streets/tree/main/osm2lanes/src transforms OSM way tags and describes the lanes along a road from left-to-right. Right now it uses hardcoded lane width values from https://github.com/a-b-street/osm2streets/blob/ddc26753b36afe49121b0fe6b523a3293f9281ee/osm2lanes/src/lib.rs#L279. Sometimes lane widths are tagged in OSM, so we should use them when they are. There's a few different width tags that we could use; one simple one is sidewalk:left:width (https://wiki.openstreetmap.org/wiki/Sidewalks#Sidewalk_as_refinement_to_a_highway).

iakev commented 12 months ago

Hi, @dabreegster I would like to take up this issue. As previously highlighted, I would like to focus on the Rust part, however if you could share some links that I can use to get up to speed on OSM domain knowledge and guidance I would highly appreciate it.

dabreegster commented 12 months ago

Hi! For some OSM tags related to width, see https://wiki.openstreetmap.org/wiki/Key:width#Width_of_streets. I would start with the cycleway, sidewalk, and parking lane cases (for when those are part of the main road, and not separate objects). You can use Overpass Turbo and TagInfo to find real-world examples in OSM, like https://taginfo.openstreetmap.org/keys/cycleway:left:width#overview and https://overpass-turbo.eu/s/1Bqk (click Wizard to edit the query). Those can be used to start new unit tests in https://github.com/a-b-street/osm2streets/blob/main/osm2lanes/src/tests.rs. Those tests currently ignore width in the output; I would vote for starting new tests similar to the old, that specifically check for width in some of the output lanes (but not all -- we probably won't know for most of them)

The logic changes would happen in https://github.com/a-b-street/osm2streets/blob/main/osm2lanes/src/algorithm.rs. There's an apply_width function that happens after the main pass. That might be a good place to apply this logic -- you'll already have the lanes left-to-right, so if you see something like a cycleway on the right, you could search in one direction for it. Or maybe it's easier to parse these lane overrides when that lane is first found -- not sure.

Let me know if you get stuck with anything, whether it's Rust, OSM, or otherwise. Thanks for helping out on this!