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

Maybe split long roads into smaller segments ? #1

Closed marco44 closed 11 years ago

marco44 commented 11 years ago

Hi, First, I must say this program rocks.

I just have for now a small problem: in my area, there are some long roads, where only a small part (a few kilometers) is very good. The consequence is that either the road is not displayed (rare), or has a low score, and that 50 kilometers are marked as «nice», when 5 kilometers are interesting.

Would it be possible to have an option to split roads into smaller parts ? Then it would display the interesting parts, instead of whole roads, and would depend less on how it was mapped in OSM (one long or several smaller consecutive ways).

Regards

adamfranco commented 11 years ago

Hi Marco, thanks for the request. This is something I've been thinking about adding for a while. What I haven't decided on yet is the best way to break up roads. My current thought is to set a distance threshold (defaulting to something like 1 mile) and split a road if it has been more than a mile since the last segment that had a radius smaller than the minimum. All 'straight' segments would then be ignored until the segment with a radius smaller than the minimum. Hopefully I can get some time to work on this in the next few weeks or months, but feel free to submit a pull-request if you get something working before then. :-)

marco44 commented 11 years ago

Hi,

I wish I could help. Alas, I'm a C and Perl developper, usually. I have no competence in Python whatsoever, except for launching the program :/

Anyway, yes, I totally agree with you on the algorithm: just cutting a road when it gets over a threshold seems good and reasonably simple to me. As for the threshold, I dont't know. Obviously, it should be a runtime parameter. I don't want it to detect too small curvy segments (I won't do 50 miles just to drive a 1 mile segment :) )

My point was more on the «fairness» side: here, there are very long segments of road, and it is really unfair to compare your curvature score of a 50 kilometers segment with one of 2 kilometers.

adamfranco commented 11 years ago

@marco44 , this feature is now ready for use. You may want to try values other than the default of 1.5 miles for the split threshold to see what gives you the best output.

Example:

./curvature -v --straight_segment_split_threshold=2.5 vermont.osm

Enjoy!

marco44 commented 11 years ago

I've been running it all over France, and asked a bunch of friends about their respective regions. I'll keep you informed.

Just one tiny thing: most of us use kilometers, not miles. It's not that big a deal, it just feels weird to use this unit :)

adamfranco commented 11 years ago

It's funny you mentioned the units. All of the internal calculations are done using meters, but the command-line parameters all use miles (I'm American after all :smile:). I had originally had this parameter using kilometers, but then realized that could be confusing since the other parameters like --min_length and --max_length use miles. At some point I may add support for unit suffixes, but I have a few more interesting features lined up first. :smiley:

P.S., I think this is my first significant Python program (I do most of my work in PHP), and I've found Python to be quite approachable -- just edit any of the .py files with a text editor, save them, then execute again. :yum: If you add support for parsing unit suffixes on the command-line parameters, just submit a pull request and I'd be happy to integrate it.

marco44 commented 11 years ago

Yeah, but I didn't use the other parameters, so it didn't even occur to me they were in miles :)

Anyway, I already tried writing Python, and I just think my brain's not made for it…

On 30/05/2013 18:02, Adam Franco wrote:

It's funny you mentioned the units. All of the internal calculations are done using meters, but the command-line parameters all use miles (I'm American after all :smile:). I had originally had this parameter using kilometers, but then realized that could be confusing since the other parameters like |--min_length| and |--max_length| use miles. At some point I may add support for unit suffixes, but I have a few more interesting features lined up first. :smiley:

P.S., I think this is my first significant Python program (I do most of my work in PHP), and I've found Python to be quite approachable -- just edit any of the |.py| files with a text editor, save them, then execute again. :yum: If you add support for parsing unit suffixes on the command-line parameters, just submit a pull request and I'd be happy to integrate it.

— Reply to this email directly or view it on GitHub https://github.com/adamfranco/curvature/issues/1#issuecomment-18690183.

marco44 commented 11 years ago

The new algorithm seems quite good. Friends confirm that the good roads in their areas are detected correctly.