-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intersection consolidation: geometry #62
Comments
…#654 Problems at i558, i147 and the Mill/13th one still crashes
Alright this is pretty exciting. I got "Wild alternative number 1" pretty much working in https://github.com/a-b-street/abstreet/tree/consolidate_differently. There are some rough edges, but I'm convinced this is the way forward. I'm focusing on consolidating all the intersections in the Tempe map first, while not breaking anything in Seattle. My plan:
Then assuming everything's good, lots of exciting cleanup:
|
…swapped quickly. Using this for more rapidly testing intersection consolidation algorithms. #654
…undo a tested merge operation. #654
It maintains a JSON file of ways to merge that the importer also uses. For maps fast to import, this is the nicest workflow. Unlike map_editor, turns and trimmed roads can also be checked.
…gorithm... #654 Phinney gridlocks again; 68daa68 was too ambitious. Otherwise all fine!
…gorithm... #654 Phinney gridlocks again; 68daa68 was too ambitious. Otherwise all fine!
… map_editor's ability to preview one intersection with the debugging geometry. #654
…e JSON list of ways to merge. #654
intersection. This often happens with a group of 4 intersections (two divided highways), and there may be many small segments embedded in the middle for street car tracks and such. Also bring in fresh OSM for Tempe, with one such intersection now consolidated! #654, #672
…into merging! #654 Manually invoked heuristic for the moment, and has some issues, but a start.
…eft-handed maps. #654 Not regenerating yet. (There shouldn't be many junctions tagged on non-US maps, at least not by me.)
… that try to merge short roads #654
…n of short roads from transforming them. #654 And add a convenient script to diff changed maps. (Motivated by preserving the fixpoint behavior in Montlake)
Borders now seem to be skipped correctly. Having a hard time skipping dual carriageways based on angle. Aiming to enable first for Montlake, then gradually rollout to individual maps, solving problems very incrementally and without regressions.
Making progress here. Approximate next steps:
|
Just had a quick look at the issues and possible solutions above. No specific input but just wanted to say big general 👍 on progress. The hardest problems in software are often the last ones to be tackled but seems there could be benefits of 'grasping the nettle' on this one. If you want any input from me, or before/after tests, happy to help. |
Win-win-win-win solution! |
Not sure, could spout some suggestions but don't feel well enough informed to do so at this point. |
I don't understand the pre-trimming crash at all, but I think I'm going to take the easy way out for now, avoid crashing, not pre-trim, and just plow forward. It works in this case: Now attempting to roll out the de-dog-leggification to all maps... |
Feel free to, but no pressure. https://a-b-street.github.io/docs/tech/map/geometry/index.html#a-solution-two-passes describes what's happening here. It takes me about 3 days of full concentration to shove all of this back into my head; I don't find it simple. :\ Which is partly why progress is so slow. |
It's pretty intense computational geometry going on here! Over my head and above my pay grade. Could help drum up interest in a call out to computational geometers interested in programming on Twitter and other platforms if that becomes appropriated at any point. As with many domains of human interest, there's a surprisingly large community of them, not least the 100s of people involved, directly and indirectly, to CGAL: https://www.cgal.org/people.html and the source code: https://github.com/CGAL/cgal People love a challenge. |
More motivation why this has downstream effects. When the geometry is broken enough, the LTN tool can't trace blocks, and the whole idea just kind of keels over. This is a "base" problem I've been trying to solve more robustly since forever. Before: Also, I declared victory too soon -- many map crashing trying to use this new code. I'll keep iterating...
That would be fantastic, but let me split out the code / problem first: #3. The first steps I took yesterday towards this were what let me make progress today. |
Awesome. Interested to see what happens when a call out to the computational geometry community is made, will let you take the lead on that but of course happy to help out where I can. |
Next thing to fix is merges near roads that loop, like https://www.openstreetmap.org/way/26815503 and https://www.openstreetmap.org/way/13868806 |
…ly not on a road's center line, just skip instead of crashing. This allows us to roll out the dog-leg intersection merging for many more maps and see pretty much universal improvement in map geometry! #654 [rebuild] [release]
There are some other issues already for merging short roads, but I want to dump some recent notes about the geometry problem in particular.
Current approach
Code at https://github.com/a-b-street/abstreet/blob/master/map_model/src/make/merge_intersections.rs
The
RawMap
produced from OSM looks something like this. The pink segments have been manually tagged by me asjunction=intersection
in OSM, which often requires splitting the way. It's not too hard to auto-detect these segments and avoid the tagging. The problem is that the current algorithm for consolidating these intersections breaks in most cases, so I'm using the tagging as a way to manually opt in a few cases that I've worked on and verified turn out reasonably.The current algorithm will take each pink segment in a pretty arbitrary order and do the following. It'll delete the segment and one of the intersections (arbitrarily), preserving the other intersection. It takes all of the roads connected to the deleted intersection, and reassigns them to be connected to the surviving intersection. It does some work to preserve the various types of OSM turn restrictions, some of which are implemented, some not. But then it also modifies the polyline geometry of some of the roads, to account for the deleted segment. The animation explains best:
The top intersection was deleted, so those 3 connecting roads have their polyline extended to roughly cover the deleted segment.
Then we proceed with map generation as usual, and the intersection geometry algorithm described elsewhere sometimes produces something half-reasonable:

But often it does not:


New idea
Do we always want to extend the geometry of surviving roads by that one new point? Maybe we don't need to extend any polylines at all, or maybe we should only extend the ones of non-pink segments, aka, normal roads that'll survive this process repeating. Maybe we should move the last point instead of adding, or add all of the points of the short road removed.
I added 2 new enums to quickly explore all of these combinations. One example worked much better for the case above:


But applying that policy everywhere broke another case that was previously working:
So is there a way to identify when we should
AddOnePoint
and when we shouldModifyWhichRoads::None
?Wild alternative number 1
I've probably tried some form of this in the past. Often the original intersection geometries turn out reasonably:

What if we used these to decide how much to trim back the surviving roads, then deleted the pink segments, did the turn restriction fixing, but didn't modify any geometry? And mark that these intersections were "pre-trimmed" and skip part of the intersection geometry algorithm, and just construct the final polygon.
If this even works, would it blow up with road widening?
Wild alternative number 2
https://wiki.openstreetmap.org/wiki/Tag:junction%3Dyes#How_to_use_on_an_area
There are a few different proposals for tagging intersections as areas in OSM. I haven't checked Overpass yet, but I'm pretty sure I've seen a few of these mapped before. This particular scheme is purely additive; it shouldn't break any existing OSM software. Maybe in these really hard cases, it'd be much faster to just draw the polygon by hand in OSM from satellite imagery, and make the importer understand these as overrides. Haven't thought through how that import would work. Also not sure what to do if abst infers very different road width than reality and winds up disagreeing strongly with the human-mapped polygon.
The text was updated successfully, but these errors were encountered: