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

Interpreting negative space #250

Closed dabreegster closed 6 months ago

dabreegster commented 6 months ago

A first step towards #248. Not ready to merge yet, but I wanted to open for feedback on how to use this.

This PR introduces a way to start at a road or intersection, then find a small cycle starting and ending on it, and generate the polygon that (approximately) fills the negative space between everything. Based on the types of roads and intersections in that cycle, the "block" gets classified as a few different cases.

image The green polygon represents the area between a road and a separately mapped sidewalk. Assuming the road width and sidewalk placement is roughly accurate, then this could have a few interpretations. Sometimes it's a wide pavement, or the planter strip (or "verge"?) often found in suburbia: image

image The purple polygon is the space between dual carriageways. In OSM, a road is split into a dual carriageway when there's some kind of phyical separation between the two sides, not just paint. We could try and render something here, maybe.

There are more cases I'll add, like the space between a cycleway and road (hopefully some kind of separation for the cycleway) or the space between cycleway and sidewalk (maybe separation, or maybe just a little curb).

For this first step, I think I just want to settle for finding the polygons, classifying them, and rendering in an off-by-default layer for debugging. I'll first work on finding all of the blocks (problems handling both sides of a road and dealing with dead-ends) and improving the classification.

But more ideas in #248 could come later. We could also change the block-tracing logic to only follow sidewalks and crossings, and wind up with a nice big junction shape around all of something like this: image In that case, the big polygon is probably less useful. Seeing all of the Intersections and Roads inside is useful, because then we can reason about vehicle stop lines (behind the crosswalks, probably) and generate high-level movements through the whole junction.

Or similarly, we could try to group all of the parallel-ish OSM ways and have a higher-level representation of all of the street features from right-to-left, no matter how they're split up in OSM. Answering if https://www.openstreetmap.org/way/422264711 has a sidewalk is not straightforward, but with this kind of grouping, it would work.

dabreegster commented 6 months ago

Alright, I got the block-finder to pretty much handle everything except dead-ends / edge of the map. Added a few more categories in the classification, but each of them still needs some work. And improved the debugging UI a bit. Going to merge and take smaller steps.

image image

dabreegster commented 6 months ago

CC @andrewphilipsmith and @sgreenbury as FYI; this was the idea I described earlier this week