adamfranco / curvature

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

Rolling up curvature scores for ways and collections #42

Closed Fonsan closed 3 years ago

Fonsan commented 8 years ago

Looking at https://github.com/adamfranco/curvature/blob/061ea383c78b1dbd82aafd8b95bdcde5f2005774/curvature/post_processors/roll_up_curvature.py#L25

The curvature score is summed over segments without taking into account the segment length and the same goes for ways into collections.

The segment curvature score is weighted by length https://github.com/adamfranco/curvature/blob/c93f7047ec0b9c4359872820fdba433d4d221669/curvature/post_processors/add_segment_curvature.py#L8 so it does not suffer only when we aggregate them for ways and collections.

This leads to a few caveats; A way with a curvy section like a mountain road that later leads into a long valley would have a equal or higher curvature score than the same road without the straight segments in the valley. Given a long enough road it will always get a high curvature score which seems plain wrong. Use of the straight segment splitter remedies this somewhat but it is omitted most highways in Europe get a mid range curvature score.

The specification of the algorithm seems broken for the cases above and I would like to suggest a new distance weighted score in which would be the average curvature per distance that would be a score from 0 to 1.0 where 0 is a completely straight line and 1.0 would be defined as every segment of the road having a turning radius of some constant value or more. I realise this will require a new major release but calculating a average score is a deal breaker for my use case

adamfranco commented 8 years ago

Hi Eric, sorry to take so long to get back to you, I've been traveling for a few weeks without a computer. :-)

This leads to a few caveats; A way with a curvy section like a mountain road that later leads into a long valley would have a equal or higher curvature score than the same road without the straight segments in the valley. Given a long enough road it will always get a high curvature score which seems plain wrong. Use of the straight segment splitter remedies this somewhat but it is omitted most highways in Europe get a mid range curvature score.

Back in 2013 straight-segment splitting was added to fix the first reported issue #1 with curvature. Omitting the straight-segment splitting certainly would create a problem, but what is it that you hope to gain by omitting that step? My overall goal with the program (at least its default output) is to highlight "continuously fun segments" that an end-viewer can reference to link together a tour/route that combines as many fun turns as possible. In the example you provide, I'd explicitly want to "mute"/"hide" the straight valley section in order to highlight only the curvy mountain section. Since most long routes have both curvy sections and straighter sections, I want to highlight just the curvy sections so that it is easy to see where one should get onto the road and where one would have more fun turning off to an alternate road.

While there certainly is nothing wrong with adding a post-processor that would add an average curvature per distance parameter, my hunch is that basing output on that rather than splitting on straight segments will hide many great segments in longer numbered routes. As we look at world-wide output, this is likely something that would be influenced by local road-numbering practices. In the U.S. we have national routes that often cover thousands of miles, state-routes that will cover several hundred miles, and county-routes that will often only be a few miles. Just due to the differing numbering schemes, national-routes will almost always have huge lengths that would prevent them from ever getting a significant average curvature per distance. Conversely, the shorter average length of the county routes would cause any curves to give them a large average curvature per distance.

In the extreme case, a 0.25 km road with 0.25 km of turns would have a 'perfect' average curvature per distance while a 100 km road with 50 km of turns would have a lower average curvature per distance score. I'd want to highlight as much of the best 50 km of the latter road more than the short segment as it would be more worth a trip to ride for me.

adamfranco commented 3 years ago

Closing as out-of date.