Coder Social home page Coder Social logo

Display lane tagging about map-machine HOT 18 CLOSED

dabreegster avatar dabreegster commented on May 24, 2024 1
Display lane tagging

from map-machine.

Comments (18)

enzet avatar enzet commented on May 24, 2024

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!

from map-machine.

dabreegster avatar dabreegster commented on May 24, 2024

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.

from map-machine.

enzet avatar enzet commented on May 24, 2024

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.

from map-machine.

enzet avatar enzet commented on May 24, 2024

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.

from map-machine.

dabreegster avatar dabreegster commented on May 24, 2024

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.

from map-machine.

enzet avatar enzet commented on May 24, 2024

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

Screen Shot 2021-05-29 at 22 29 06

from map-machine.

enzet avatar enzet commented on May 24, 2024

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.

from map-machine.

enzet avatar enzet commented on May 24, 2024

Simple implementation of intersection drawing:

Screen Shot 2021-06-01 at 02 22 39

from map-machine.

dabreegster avatar dabreegster commented on May 24, 2024

Looking like solid progress!

Just stumbled across http://blog.imagico.de/navigating-the-maze-part-2/, with more ideas about rendering lane detail

from map-machine.

enzet avatar enzet commented on May 24, 2024

Just stumbled across http://blog.imagico.de/navigating-the-maze-part-2/, with more ideas about rendering lane detail

Oh, wow! Yeah, I thought about something like this. But this is way more complicated than I imagined. Now I have just simple lanes and one color:

Screen Shot 2021-06-01 at 04 58 06

from map-machine.

dabreegster avatar dabreegster commented on May 24, 2024

Now I have just simple lanes and one color:

Whoa, this is looking really nice. I think this approach is simpler than A/B Street's -- I try to maintain the invariant that each lane hits the intersection polygon at 90 degrees. Vehicles use that as the stopping line. But this example in reality looks closer to your rendering; the stop line probably is still perpendicular to each lane, but the position may be different for each lane on one segment.

from map-machine.

enzet avatar enzet commented on May 24, 2024

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

from map-machine.

dabreegster avatar dabreegster commented on May 24, 2024

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

from map-machine.

enzet avatar enzet commented on May 24, 2024

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.

from map-machine.

enzet avatar enzet commented on May 24, 2024

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.

from map-machine.

dabreegster avatar dabreegster commented on May 24, 2024

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!

from map-machine.

dabreegster avatar dabreegster commented on May 24, 2024

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.

from map-machine.

enzet avatar enzet commented on May 24, 2024

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.

from map-machine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.