adamfranco / curvature

Find roads that are the most curvy or twisty based on Open Street Map (OSM) data.
http://roadcurvature.com/
225 stars 39 forks source link

Road Continuity Issue #62

Open markongh opened 3 years ago

markongh commented 3 years ago

Describe the bug I have found at least one example of a road that is broken into multiple sections when it should be treated as a single continuous road. I suspect there could be many more.

To Reproduce Steps to reproduce the behavior:

  1. Go to this location in RoadCurvature: https://roadcurvature.com/map/#map=16.621/14.7397/40.931
  2. See that the single road is missing two sections that should be included in the road curvature analysis (see screenshot below).

Expected behavior This road should be analyzed as one continuous road in roadcurvature.

Screenshots image

Desktop (please complete the following information):

Additional context I looked into the data in OSM and discovered that the road names and numbers were inconsistent at this sections of road and changed them to be consistent through the entire section. I am unsure if that is what was causing the continuity problem because I did this about 5 min ago and I am assuming it will take time for the change to reach all the relevant servers. However, this does cause me to wonder if you are using road names/numbers to determine where a road might start or end. I would think this should not be the case since roads can change names sometimes in the middle of a continuous section. The other possibility is that it was caused by two very short segments of road in this locations which may have caused the algorithm to not count those. I am not completely sure as I have not dug into the code (I haven't coded in over a decade), but I suspect there are other examples of this occurring which may be eliminating or reducing the curvature score of potentially awesome roads.

adamfranco commented 3 years ago

Thanks for reaching out with the detailed report about this, @markongh. Your data-fix should cause the road to show up continuously on the map the next time the Italy data-set gets processed. It normally takes about 3-4 weeks to work its way around the globe one country at a time. I flagged Italy to be refreshed sooner, so it should be updated in a few hours.

While not perfect in all cases, I haven't yet hit on a better way to conceptualize a "continuous road" that doesn't use route-number or name. Route-number in particular works well for the roads in many countries as it includes most major routes that span regions -- it doesn't matter if the classification changes for sections or the name changes, as long as there is a continuous sequence with the same route number, then they can be easily joined together. Names are a bit tougher since a given region might have many roads with the same name (most towns in my area have a "Main Street" and a "High Street"). As you allude to, the name of a road may also change arbitrarily, often at municipal boundaries.

Curvature only uses the name for road joining when there is not a route number, limiting the scope of this issue to smaller roads that are not part of numbered routes. It may be possible to join differently named roads together, but I think that would be only appropriate if the highway classification was the same and there weren't also other roads branching off from the same (or nearby location). For example, if a tertiary road ends and 3 residential roads split off from it near the end, it wouldn't necessarily make sense to tack on one of these residential roads to the end of the tertiary road. If the roads were all the same classification, it would be pretty easy to get wrong as well and choose to continue on a road that isn't locally though of as a continuation.

A local-to-me example of a name-change on a "single road" is Bethel Mountain Road/Rochester Mountain Road/Camp Brook Road (OSM). These three sections of Tertiary road form what is locally known to be a single road, but I wouldn't want to accidentally join on the smaller "Hooper Hollow Road".

Screen Shot 2021-01-31 at 3 23 22 PM

I'll think about this one some more to see if I can think of ways to do this that wouldn't create "roads" that wouldn't pass a local sniff-test of being "the same road". :-)

adamfranco commented 3 years ago

Italy has now been reprocessed after your data fixes and SS374 now shows up as a single much more twisty road: Screen Shot 2021-02-01 at 8 32 07 AM

markongh commented 3 years ago

@adamfranco, thanks for the quick response! I think this is an awesome tool, and I can definitely appreciate the trickiness of this problem, especially after seeing the example you provided. I also have a better understanding of how/why you use the route number/name to determine road continuity. I'm glad to see that the route number was the cause of the issue for the road in Italy because it means the problem was with the OSM data and not necessarily how RoadCurvature is working. I don't know your opinion on this, but I would encourage you to have a similar philosophy of OSM of "not tagging for the renderer." In other words, build and code RoadCurvature assuming perfect and complete OSM data. If it results in highlighting some roads that are not ideal due to poor OSM data, then as these areas are explored and a fix is applied to the OSM data, it will fix the output of RoadCurvature.

To offer some of my off-the-cuff thoughts: In the case of the road in Italy, my initial thought was that it should be recognized as single road because there were no intersections of other roads (only maybe footpaths) at the points at which it was excluding sections of road.
One possible way to check for road continuity is a checking at each node to determine how many ways are connected to that node. If one way is connected to the node, you are at the end of the way (-.), if two are connected (-.-) you are in the middle of a way and the road is continuous, if three or more are connected (-.<) you are at some kind of intersection and other criteria would need to be evaluated (such as traffic lights, stop signs, way type, etc) to determine which direction to continue, if at all. I saw that you already take street signs/traffic lights into consideration which I think is excellent and recommend you should continue with for this purpose. I also thought of possibly looking at left turns from a two-way road (since you would have to yield to on-coming traffic) but realized additional evaluation of the roads at the intersection (maybe angles of the ways connecting to the last evaluated way) would have to be done to determine what is "left" vs. "straight." I don't know if you take into account direction of travel for this, but that could also present an issue since a left turn from one direction which may require a yield to oncoming traffic would be a right turn from the other direction possibly not requiring a yield and the right turn (absent any traffic lights) and could be treated as a part of the route.

I hope that was understandable as I was still thinking through it as I wrote this haha. Hopefully it helps as you also continue to think about it. I'd love to hear your thoughts. Thanks again!