Skip to content

Display lane tagging #45

Closed
Closed

Description

@dabreegster

Hello, this is a really exciting project to see! I'm curious if you're thinking of showing details along roads, such as number of lanes, dedicated cycle/transit space, parking, turn lanes, and such. If so, I may be able to help a bit -- I work on A/B Street and have been struggling for a while to render OSM roads in high detail. A quick demo:
Screenshot from 2021-05-25 06-19-53

Possible ways to collaborate:

  • I have a function that tries to turn the key/values for a single OSM way into a left-to-right sequence of lane specifications, including width, type, and direction. The code is in Rust, but it would be relatively straightforward to port the logic to any language. I also have some unit tests encoding some of the trickier cases I've hit.
  • Brainstorming about design

Thanks, and keep up the awesome work with this renderer!

Activity

  1. enzet commented on May 26, 2021

    @enzet
    Owner

    Hey! Thank you!

    A/B Street is a really great project! I'm used to checking it out from time to time. It's exciting how much information we can get from OSM!

    For now, I use just road class to determine its width. And I was thinking of using width and lanes tags. As well as width:carriageway, parking:lane, and others.

    Since the final goal of the project is to show all the richness of the OpenStreetMap data, I'd be happy to be able to visualize all information about lanes, signs, road markings, and pedestrian crossings. Any help on this would be just great! I have some experience in creating transit maps, so maybe I can use some ideas from that as well.

    Thanks for your interest! I'm looking forward to cooperating!

  2. dabreegster commented on May 27, 2021

    @dabreegster
    Author

    And I was thinking of using width and lanes tags. As well as width:carriageway, parking:lane, and others.

    Unfortunately the width tags aren't often used, because it's pretty hard to measure without unobstructed imagery and software, or some pretty dedicated on-the-ground work. Just be warned that trying to render width based on lanes and some guesses for width of each lane type can lead to problems with overlapping roads:
    Screenshot from 2021-05-26 19-57-53
    This kind of thing happens either because the road's center is a bit offset, or the lanes tagging is wrong, or the guesses for lane width are. I think it'd be great to have more renderers show this, so mappers are incentivized to fix some of the problems.

    I'd be happy to be able to visualize all information about lanes, signs, road markings, and pedestrian crossings. Any help on this would be just great!

    What I can offer for the moment is https://github.com/a-b-street/abstreet/blob/master/map_model/src/make/initial/lane_specs.rs. This is lots of code, but the overview is simple. It takes the key/values for a way, and generates a list of LaneSpecs in order from left-to-right. Each LaneSpec has a width, direction (forwards/backwards, relative to the way), and type (driving, bus-only, bike, parking, etc).

    There are tests at https://github.com/a-b-street/abstreet/blob/e4a95b604e36d3c24394c1c8afd726202e924374/map_model/src/make/initial/lane_specs.rs#L355 that capture some of the behavior. I've thought about encoding the test cases in some easy-to-parse format and popularizing them within the OSM community. It'd be great if different software could agree about the interpretation of them. The code I have so far gets lots of things wrong, and my hope is that there's a way to let people with much more OSM tagging expertise than me write up test cases, even if they don't want to dive into programming.

    If you want, I could extract parts of this code so that you could call it easily. This could either be a library that you link against from Python, or a command-line tool that you call. The output could be these LaneSpecs in JSON or something easy to parse.

    I have some experience in creating transit maps, so maybe I can use some ideas from that as well.

    This is unrelated to this issue, but a general question: do you think it's feasible to transform a road network from OSM into a transit map automatically? Distorting distances, curves in the road, and angles would all be fine, as long as the result is topologically equivalent to the original. I've been curious about this problem for a while, because it could be a nice way to avoid rendering headaches with intersections having roads join at every possible angle.

  3. enzet commented on May 28, 2021

    @enzet
    Owner

    You’re right about problems with tagging. I faced it when tried to tag roads with some JOSM visualizer for lanes. I agree, that it's important to highlight errors instead of hiding or somehow trying to fix them.

    If you want, I could extract parts of this code so that you could call it easily. This could either be a library that you link against from Python, or a command-line tool that you call. The output could be these LaneSpecs in JSON or something easy to parse.

    Thank you! I feel like connecting two and more roads is the more challenging task and I want to start with it and add other lane information later. Some first sketches:

    lanes

    I didn’t still choose the license for the code. How do you think, which one should I choose? I'm considering MIT and Apache 2.

  4. added 4 commits that reference this issue on May 28, 2021
  5. enzet commented on May 28, 2021

    @enzet
    Owner

    do you think it's feasible to transform a road network from OSM into a transit map automatically?

    Do you mean something like bus network maps? I've been working on underground transit maps. It's more a graph visualization task, but I think, it's quite similar.

    Of course there are many parts of the process that can be automated, but I believe, if we want to do the whole thing fully automatically and meet some complex aesthetic criteria, we have to use some kind of ML algorithms.

  6. dabreegster commented on May 28, 2021

    @dabreegster
    Author

    I feel like connecting two and more roads is the more challenging task and I want to start with it and add other lane information later.

    Agreed. In case it's helpful, https://wwwtyro.net/2019/11/18/instanced-lines.html has a good geometric explanation of how different thick line joins work. Calculating the polygon representing the junction can be a hard problem, but your sketches look great so far. I have some notes about what I've tried here and here.

    Does the algorithm in your sketch pick a fixed distance to "trim back" the intersection from the road? Or are you first widening both road segments, then taking the overlap? I've tried variations of the latter approach, but hit issues with 3-way "T" intersections, IIRC.

    I'm considering MIT and Apache 2.

    I'm not knowledgeable about licenses; I think MIT is similar to Apache, except just much simpler to read?

    Do you mean something like bus network maps?

    Maybe. I mean simplified maps where the lines tend to meet at 90 or 45 degree angles. Distances and exact position are distorted, but the graph structure is easier to understand.

    2820by202728-3

    I think I've tried putting a road network from OSM into graphviz and trying different algorithms there to lay out the graph, but the result didn't work. Using ML to minimize some aesthetic cost function makes sense. I was just curious if you had thought about this problem much.

  7. added a commit that references this issue on May 29, 2021
  8. enzet commented on May 29, 2021

    @enzet
    Owner

    First step. Pretty naïve support of road width based on lane number:

    Screen Shot 2021-05-29 at 22 29 06

  9. enzet commented on May 31, 2021

    @enzet
    Owner

    I have some notes about what I've tried here and here.
    Wow! Great manual! Seems like it really hard task. Rounding the corners is definitely not what I should start with.

    Or are you first widening both road segments, then taking the overlap?

    Yes, I was trying to compute the overlap. Now I think, it's the most challenging task. Especially when there are many roads in an intersection. It should be a lot of fun!

    I'm not knowledgeable about licenses; I think MIT is similar to Apache, except just much simpler to read?

    Thank you and sorry for the unrelated question. MIT it is then.

    I mean simplified maps where the lines tend to meet at 90 or 45 degree angles.

    I've tried to generate some maps like this. But from Wikidata, not OpenStreetMap. It's pretty technical task if you have manualy selected node positions or just specify directions for the lines and use predefined space between nodes. For example, I can create maps like this (it's for trams but nevertheless I use underground map style):

    Screen Shot 2021-05-31 at 03 08 07

    But when I try to automatically arrange nodes using their geo positions, and, more important, try to assume best label position automatically, the task became too complex.

  10. added 2 commits that reference this issue on May 31, 2021
  11. 11 remaining items

  12. added 3 commits that reference this issue on Jun 1, 2021
  13. enzet commented on Jun 5, 2021

    @enzet
    Owner

    Well, I have to admit, that I'm stuck. Have no idea what to do with acute and almost straight angles.

  14. dabreegster commented on Jun 5, 2021

    @dabreegster
    Author

    Do you mean something like:
    acute
    If you just take the intersection between the thickened road polygons, then yeah, it won't be what you expect.

    I actually special-case intersections between only two road segments, just picking some hardcoded value to trim each road center-line back from the common point, and making a fixed quadrilateral shape.

    More generally my approach is described at https://docs.google.com/presentation/d/1cF7qFtjAzkXL_r62CjxBvgQnLvuQ9I2WTE2iX_5tMCY/edit#slide=id.g6201f22714_0_16. I really need to write up a full article about this problem, since it's so interesting and has so many edge cases. The quick visual summary is calculating the left and right side of each thickened road:
    Screenshot from 2021-06-05 16-05-40
    Then finding intersection points of those road edges. When you find an intersection, take a perpendicular line to figure out where along the original road center-line that is. Trim the center-line back to that point. If there are multiple hits due to different pairs of road edges, trim back the farthest distance.
    Screenshot from 2021-06-05 16-05-51

    This results in bigger intersection polygons than your approach, since it forces roads to hit the polygon at right angles. That's not realistic sometimes. And there are still problems sometimes, like the lower left corner:
    Screenshot from 2021-06-05 16-07-55

  15. added 2 commits that reference this issue on Jun 7, 2021
  16. enzet commented on Jun 8, 2021

    @enzet
    Owner

    Do you mean something like:

    Yes, exactly like that! Even when there are more than two roads intersect.

    Screen Shot 2021-06-09 at 01 42 53

    I actually special-case intersections between only two road segments

    Yeah, I've added some obvious hacks for these cases but still don't like the results.

    This results in bigger intersection polygons than your approach

    It seems like I use exactly the same approach. Thank you for the descriptions. It's very helpful. I have some more ideas to try.

  17. added a commit that references this issue on Jun 21, 2021
  18. enzet commented on Sep 16, 2021

    @enzet
    Owner

    Hey, @dabreegster!

    I was working on tile generation and recently returned to this issue. I've added lane drawing based on @imagico work and planning to add lane delimiters, special lane drawing, and sidewalks. Do you think it is the right direction of developement?

    lanes

    This issue seems to be too big. Is it OK if I convert this issue into a discussion? I've created a project and will create separate issue like #81.

  19. dabreegster commented on Sep 16, 2021

    @dabreegster
    Author

    Yes, this looks fantastic! I forgot some context on your approach so far -- are you using highway to guess road width, or are you trying to base it on the number of lanes? An idea that I've never tried is to copy the highway-based widths that other OSM renderers use, then just divide that into the specified number of lanes. Some lanes might wind up very skinny, but since people generally draw roads in geometrically sane ways according to the default renderer, it's a way to avoid lots of problems.

    Also, I finally wrote the huge deep-dive into A/B Street's intersection geometry: https://a-b-street.github.io/docs/tech/map/geometry/index.html. I hope it provides inspiration / reference to your work here!

  20. dabreegster commented on Sep 16, 2021

    @dabreegster
    Author

    This issue seems to be too big. Is it OK if I convert this issue into a discussion?

    Oh yes, feel free! I'm a big fan of Github discussions for these more open-ended brainstorms.

  21. enzet commented on Sep 17, 2021

    @enzet
    Owner

    Thank you!

    For now, to determine road width I use the width tag value (when present) or estimate it as 3.7 × lanes value (when present). And the next step is to use width:lanes, bicycle:lanes, etc.

    Wow! Thank you for the article. It's really comprehensive! I got answers to questions that I didn't know about yet.

  22. Repository owner locked and limited conversation to collaborators on Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    generatorMap generation issues

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions