You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found this strange routing:
This first routing is much longer as the second one. I place the destination only some meters west in the second routing. The osm data looks correct.
first it is much longer. yes the time is nearly the same. from my experience in realworld this couldn't be right.
it's correct that the longer path has a smaller incline and a smother surface. But for me the distance should have more weight.
And if you look: the length of the route on highway=track is approx. as long as by the other route.
Well, that is true for you but probably not for others and that is the reason bike routing is not easy :)
Maybe you could tweak the routing a bit and avoid such a big penalty directly in the code for that area? You'll need to tweak the BikeCommonFlagEncoder. Installation of GraphHopper is trivially once you have java installed. Let me know and I'll see if that is okay for other areas too.
We will make this more flexible from outside in a later version, but this personalization won't be accessible for OSM.org I fear ...
i checked the data again in detail:
Short route: residential and track (grade1, grade2, "no grade")
Long route: tertiary, residential and track ( only "no grade")
Speed for: tertiary, residential and track-grade1 is the same -> 18
Speed for: track-grade2 and track-nograde is the same -> 12
Only from this, the short route should win.
I don't know the turn penaltis, ...
The only reason i could think is the incline. If you look at the first route: why did he took the route over the street "Kreithgasse" and not over the "Hochstraße" -> Hochstraße has a much greater incline that Kreithgasse.
I agree bicycle routing isn't easy. There are many types of bicycles, and even more types of cyclists. But since Graphhopper is now on the main OSM site, I guess you (devs) might get a lot of related questions to it. So maybe it's not a bad idea to explain some used routing principles (that way, people can adapt tagging to get better routing, or suggest improvements for the engine).
Instead of following the quiet unclassified road (even if there's no cycle lane, there's also almost no traffic on unclassified roads, so it's an enjoyable ride), it says I have to cross a tertiary road twice, and drive on a noisy cycleway next to that rather busy tertiary road. Elevation doesn't matter (even if you have that info), both routes are perfectly flat.
I know that tagging a cycleway next to a busy road is a bit contra-productive (when not tagged, I'm quite sure the router would prefer the quiet road), however, it's done quite often by now.
For this problem, I see two solutions:
Make the preference difference between cycleways and unclassified roads smaller, on average they're both equally pleasant to drive on IMO, so the shortest one should probably be taken.
Implement the class:bicycle tag to allow mappers to show how pleasant it actually is to drive on a road.
Thanks for pointing to class:bicycle, didn't know about it. Also yes, the unclassified road could get a boost.
What does class:bicycle=-1 mean?
explain some used routing principles
I would avoid to suggest mappers to map for routing engines. Just map the reality and we try to guess the best possible. In this light class:bicycle is indeed not about mapping
I know that tagging a cycleway next to a busy road is a bit contra-productive
Why is that contra-productive when it is there? Can we somehow extract that it is along the tertiary highway?
The class:bicycle tag is indeed highly subjective. And thus also has many opponents within the OSM community. If you have other ways to improve tagging, that's also welcome.
I would avoid to suggest mappers to map for routing engines. Just map the reality and we try to guess the best possible. In this light class:bicycle is indeed not about mapping
Similar as tagging for the renderer. Everybody says not to do it, but it happens all the time. Tagging for the renderer also has some positive results. F.e. it creates a certain standardisation in the tags. It becomes bad when you tag false facts to influence a particular renderer. In this light, a clear description on matters like "what tags are taken into account", "for what sort of cyclists the routes are meant", ... would be very positive I guess.
That way, people can see what part of the reality is missing in their tagging, and add it.
Why is that contra-productive when it is there? Can we somehow extract that it is along the tertiary highway?
Well, by adding a track next to it, instead of tagging the existence of a cycleway on the main road, you lose the obvious connection between the two. So routers can't see some of the finer details (f.e. the name of the road, some of the crossings might be strange due to missing links, ...). Extracting the environment is possible of course, but I don't think there's any router implementing this currently due to the difficulty.
Other tags can be added, like the distance between the cycleway and the road, the type of separation (grass, hedges, trees, ...), the classification of the closest road, the name of the closest road, ... However, this might add tag duplication that's not really wanted.
The finding in the example above is mostly triggered by the way 161774102, which is currently mapped as "track" without any other tags (tracktype, surface). In this case we assume pretty bad cycling conditions (if you look closely it instructs you that you might need to get off) and as this segment is rather long, the longer paved de-tour is preferred.
See
I was well aware about the class:bicycle existence during the bicycle routing tweaking. Parts of the ideas made it into the graphhopper code. I didn't include the tag "class:bicycle" support, because I believe that first place the common highway tags should influence the decisions, the class:bicycle tagging is pretty controversial and not often used.
It is a pity that only the default bicycle routing is online. Graphhopper also supports MTB and racebike, but the online instance does not activate it. In the example above, choosing MTB would result in the tour you expected.
The proposed first solution was : "Make the preference difference between cycleways and unclassified roads smaller, on average they're both equally pleasant to drive on IMO, so the shortest one should probably be taken."
Of course this would be easily possible. But tweaking the bicylce routing that way, I also wanted to cover the case of riding with kids in the default touring bike like profile. That's probably the main reason for your example. It is very hard to find a common balance between cylceways and lower classified roads which fits everybody.
Regarding sanderd17's second solution: with support for class:bicycle: Go ahead, this implementation will be rather easy as everthing is prepared. As far as I understood, this is now the target of this #330. From my perspective it will not help a lot, see the comment above.
But sanderd17 mentioned two other things, which I would try to solve with higher priority. The first one is related to #75. For the bicycle routing, costs for crossing high priority roads (primary, secondary) should be added. As far as I know graphhopper currently does not provide a framework for that feature.
The other thing sanderd17 mentioned looks to be in the same or higher area of difficulty: Let's assume a separated highway=cycleway running in parallel to a main road / (e.g) primary. This should change down the priority e.g. to UNCHANGED. I do not think that this has already been adressed in one of the issues before.
Sorry, I won't have time for this in the next days. You'll need to debug into the elevation data and how this converts to the speed for up and down hill in bike2. It could be that the elevation is not smooth enough here, once again :(, and bike2 puts a penalty if the increase or decrease is too strong.
No problem. This issue is open for quite long now, one week more dosn't hurt.
This is what I tought. But shouldn't we see elevation spikes also in the elevation graph then?
An idea came into my mind for debugging: I could delete all the other not used way segments via JOSM and set breakpoints to the calculation of of the elevation weighting.
The elevation aware speed calculation results in speed values PUSHING_SECTION_SPEED / 2 ( =2 km/h) for the two ways in the west. So the algorithm assumes that it is not possible to ride there any longer. The incline there according to the DEM data is about 10%. I didn't notice any spikes. As the bike2 profile is not designed for strong mountainbikers, but rather for weak cummute riders, I believe that we can keep it as it is. I did see people pushing their bikes at lower and shorter ascends, and once you are pushing a bike upwards, you are slower than 4km/h. And when you ride with kids, these will need to get off the bike there.
Anyhow, it would be great to have explicit well commented test cases about incline values and the resulting expected calculated decreased speed values in Bike2WeightFlagEncoderTest. This is currently not the case. Maybe I'll create a few around Christmas.
Well, Kreithgasse instead of Hochstraße is also related to the pretty aggressive slow down of the speed adoption algorithm for incline sections. For the 200 meters long Hochstraße with 10% incline the calculated speed is only 3.2 km/h. Kreithgasse is 30 meters longer and has about 6 % incline, but here the computed speed is significantly faster with 13km/h.
Thanks again! I don't think this is unreasonable as 10% is heavy, no? But still this could need fine tuning AND maybe the elevation needs a bit smoothing (?)
Also it goes down on Kreithgasse which makes speed eventually too fast? @ratrun I suggest that you check if e.g. ele values of 10%, 5%, 0%, -5%, -10% and speeds like 5, 10, 15, 20, 25 should be checked and the decrease and increase compared to real world. I'm was not a good guesser in this subject probably :(
Furthermore the current increase and decrease delta is based on tower nodes (double eleDelta = pl.getElevation(pl.size() - 1) - prevEle;) which is far from optimal but due to elevation spikes this gave better results when compared with the currently commented pillar node delta calculation (for (int i = 1; i < pl.size(); i++)).
Activity
karussell commentedon Feb 16, 2015
GraphHopper bike routing is not about the shortest path, it is about the fastest but also including priorities like avoiding ugly surface, prefering a medium increase etc. Have a look at the time. They are similar:
https://graphhopper.com/maps/?point=47.8947%2C16.1056&point=47.900074%2C16.106408&vehicle=bike&elevation=true&layer=TF%20Cycle
So what do you think is the problem with the longer path, except that is longer in the distance :) ?
ximex commentedon Feb 16, 2015
first it is much longer. yes the time is nearly the same. from my experience in realworld this couldn't be right.
it's correct that the longer path has a smaller incline and a smother surface. But for me the distance should have more weight.
And if you look: the length of the route on highway=track is approx. as long as by the other route.
karussell commentedon Feb 16, 2015
Well, that is true for you but probably not for others and that is the reason bike routing is not easy :)
Maybe you could tweak the routing a bit and avoid such a big penalty directly in the code for that area? You'll need to tweak the BikeCommonFlagEncoder. Installation of GraphHopper is trivially once you have java installed. Let me know and I'll see if that is okay for other areas too.
We will make this more flexible from outside in a later version, but this personalization won't be accessible for OSM.org I fear ...
ximex commentedon Feb 16, 2015
i checked the data again in detail:
Short route: residential and track (grade1, grade2, "no grade")
Long route: tertiary, residential and track ( only "no grade")
Track Setting: https://github.com/graphhopper/graphhopper/blob/master/core/src/main/java/com/graphhopper/routing/util/BikeCommonFlagEncoder.java#L156
Grade Settings: https://github.com/graphhopper/graphhopper/blob/master/core/src/main/java/com/graphhopper/routing/util/BikeCommonFlagEncoder.java#L116
Speed for: tertiary, residential and track-grade1 is the same -> 18
Speed for: track-grade2 and track-nograde is the same -> 12
Only from this, the short route should win.
I don't know the turn penaltis, ...
The only reason i could think is the incline. If you look at the first route: why did he took the route over the street "Kreithgasse" and not over the "Hochstraße" -> Hochstraße has a much greater incline that Kreithgasse.
sanderd17 commentedon Feb 17, 2015
I agree bicycle routing isn't easy. There are many types of bicycles, and even more types of cyclists. But since Graphhopper is now on the main OSM site, I guess you (devs) might get a lot of related questions to it. So maybe it's not a bad idea to explain some used routing principles (that way, people can adapt tagging to get better routing, or suggest improvements for the engine).
F.e., I have problems with this cycle route: http://www.openstreetmap.org/directions?engine=graphhopper_bicycle&route=50.9399%2C3.0792%3B50.9388%2C3.0662#map=16/50.9409/3.0727
Instead of following the quiet unclassified road (even if there's no cycle lane, there's also almost no traffic on unclassified roads, so it's an enjoyable ride), it says I have to cross a tertiary road twice, and drive on a noisy cycleway next to that rather busy tertiary road. Elevation doesn't matter (even if you have that info), both routes are perfectly flat.
I know that tagging a cycleway next to a busy road is a bit contra-productive (when not tagged, I'm quite sure the router would prefer the quiet road), however, it's done quite often by now.
For this problem, I see two solutions:
Thanks for the work on it
karussell commentedon Feb 17, 2015
Thanks for pointing to class:bicycle, didn't know about it. Also yes, the unclassified road could get a boost.
What does class:bicycle=-1 mean?
I would avoid to suggest mappers to map for routing engines. Just map the reality and we try to guess the best possible. In this light class:bicycle is indeed not about mapping
Why is that contra-productive when it is there? Can we somehow extract that it is along the tertiary highway?
[-]Strange Routing (Cycle)[/-][+]Improve Bicycle Routing[/+]karussell commentedon Feb 17, 2015
Related to #280
sanderd17 commentedon Feb 17, 2015
The class:bicycle tag is indeed highly subjective. And thus also has many opponents within the OSM community. If you have other ways to improve tagging, that's also welcome.
Similar as tagging for the renderer. Everybody says not to do it, but it happens all the time. Tagging for the renderer also has some positive results. F.e. it creates a certain standardisation in the tags. It becomes bad when you tag false facts to influence a particular renderer. In this light, a clear description on matters like "what tags are taken into account", "for what sort of cyclists the routes are meant", ... would be very positive I guess.
That way, people can see what part of the reality is missing in their tagging, and add it.
Well, by adding a track next to it, instead of tagging the existence of a cycleway on the main road, you lose the obvious connection between the two. So routers can't see some of the finer details (f.e. the name of the road, some of the crossings might be strange due to missing links, ...). Extracting the environment is possible of course, but I don't think there's any router implementing this currently due to the difficulty.
Other tags can be added, like the distance between the cycleway and the road, the type of separation (grass, hedges, trees, ...), the classification of the closest road, the name of the closest road, ... However, this might add tag duplication that's not really wanted.
ratrun commentedon Feb 17, 2015
The finding in the example above is mostly triggered by the way 161774102, which is currently mapped as "track" without any other tags (tracktype, surface). In this case we assume pretty bad cycling conditions (if you look closely it instructs you that you might need to get off) and as this segment is rather long, the longer paved de-tour is preferred.
See
https://github.com/graphhopper/graphhopper/blob/master/core/src/main/java/com/graphhopper/routing/util/BikeFlagEncoder.java#L66
I was well aware about the class:bicycle existence during the bicycle routing tweaking. Parts of the ideas made it into the graphhopper code. I didn't include the tag "class:bicycle" support, because I believe that first place the common highway tags should influence the decisions, the class:bicycle tagging is pretty controversial and not often used.
It is a pity that only the default bicycle routing is online. Graphhopper also supports MTB and racebike, but the online instance does not activate it. In the example above, choosing MTB would result in the tour you expected.
ratrun commentedon Feb 17, 2015
Regarding the example from sanderd17, which was
http://www.openstreetmap.org/directions?engine=graphhopper_bicycle&route=50.9399%2C3.0792%3B50.9388%2C3.0662#map=16/50.9409/3.0727
The proposed first solution was : "Make the preference difference between cycleways and unclassified roads smaller, on average they're both equally pleasant to drive on IMO, so the shortest one should probably be taken."
Of course this would be easily possible. But tweaking the bicylce routing that way, I also wanted to cover the case of riding with kids in the default touring bike like profile. That's probably the main reason for your example. It is very hard to find a common balance between cylceways and lower classified roads which fits everybody.
Regarding sanderd17's second solution: with support for class:bicycle: Go ahead, this implementation will be rather easy as everthing is prepared. As far as I understood, this is now the target of this #330. From my perspective it will not help a lot, see the comment above.
But sanderd17 mentioned two other things, which I would try to solve with higher priority. The first one is related to #75. For the bicycle routing, costs for crossing high priority roads (primary, secondary) should be added. As far as I know graphhopper currently does not provide a framework for that feature.
The other thing sanderd17 mentioned looks to be in the same or higher area of difficulty: Let's assume a separated highway=cycleway running in parallel to a main road / (e.g) primary. This should change down the priority e.g. to UNCHANGED. I do not think that this has already been adressed in one of the issues before.
ratrun commentedon Oct 5, 2015
Now that multiple bicycle types are available on graphhopper.com/maps I re-started the investigation for the observation from user ximexs at the initial report for this issue. This is the route:
https://graphhopper.com/maps/?point=47.8947%2C16.1056&point=47.900074%2C16.106408&locale=de-DE&vehicle=bike&weighting=fastest&elevation=true&layer=TF%20Cycle
The strange thing is that the racingbike profile solution is taking the expected shorter solution.
For the check, I downloaded the respective OSM data, configured
graph.elevation.provider=cgiarand comparedbike2andbike. Onlybike2is showing the surprisingly long de-tour. In my testbiketakes a similar route compated toracingbikeand 'mtb'. So the problem withbike2is definitely related with elevation wighting. One can see that also easily by comparing the solution with this shorter solution via "Hochstraße": https://graphhopper.com/maps/?point=47.8947%2C16.1056&point=47.90065%2C16.118257&point=47.900074%2C16.106408&locale=de-DE&vehicle=bike&weighting=fastest&elevation=true&layer=TF%20CycleThis solution is longer and the total ascend even higher compared to the observed solution. @karussell : Can you please take a look and give hints how this issue can be further debugged?
karussell commentedon Oct 6, 2015
Sorry, I won't have time for this in the next days. You'll need to debug into the elevation data and how this converts to the speed for up and down hill in bike2. It could be that the elevation is not smooth enough here, once again :(, and bike2 puts a penalty if the increase or decrease is too strong.
ratrun commentedon Oct 6, 2015
No problem. This issue is open for quite long now, one week more dosn't hurt.
This is what I tought. But shouldn't we see elevation spikes also in the elevation graph then?
An idea came into my mind for debugging: I could delete all the other not used way segments via JOSM and set breakpoints to the calculation of of the elevation weighting.
karussell commentedon Oct 6, 2015
If edges are short only a few meter 'spikes' would matter a lot.
You can also set a breakpoint via OSM-way-id, they are still there in the import :)
ratrun commentedon Oct 7, 2015
The elevation aware speed calculation results in speed values PUSHING_SECTION_SPEED / 2 ( =2 km/h) for the two ways in the west. So the algorithm assumes that it is not possible to ride there any longer. The incline there according to the DEM data is about 10%. I didn't notice any spikes. As the
bike2profile is not designed for strong mountainbikers, but rather for weak cummute riders, I believe that we can keep it as it is. I did see people pushing their bikes at lower and shorter ascends, and once you are pushing a bike upwards, you are slower than 4km/h. And when you ride with kids, these will need to get off the bike there.Anyhow, it would be great to have explicit well commented test cases about incline values and the resulting expected calculated decreased speed values in Bike2WeightFlagEncoderTest. This is currently not the case. Maybe I'll create a few around Christmas.
karussell commentedon Oct 7, 2015
Ok, thanks for the investigation, also maybe the real elevation is not that big @ximex ?
Still it is strange to me why the algo chooses Kreithgasse instead of Hochstraße...
ratrun commentedon Oct 8, 2015
Well, Kreithgasse instead of Hochstraße is also related to the pretty aggressive slow down of the speed adoption algorithm for incline sections. For the 200 meters long Hochstraße with 10% incline the calculated speed is only 3.2 km/h. Kreithgasse is 30 meters longer and has about 6 % incline, but here the computed speed is significantly faster with 13km/h.
karussell commentedon Oct 8, 2015
Thanks again! I don't think this is unreasonable as 10% is heavy, no? But still this could need fine tuning AND maybe the elevation needs a bit smoothing (?)
Also it goes down on Kreithgasse which makes speed eventually too fast?
@ratrun I suggest that you check if e.g. ele values of 10%, 5%, 0%, -5%, -10% and speeds like 5, 10, 15, 20, 25 should be checked and the decrease and increase compared to real world. I'm was not a good guesser in this subject probably :(
Furthermore the current increase and decrease delta is based on tower nodes (
double eleDelta = pl.getElevation(pl.size() - 1) - prevEle;) which is far from optimal but due to elevation spikes this gave better results when compared with the currently commented pillar node delta calculation (for (int i = 1; i < pl.size(); i++)).karussell commentedon Jul 9, 2022
When using the bike profile without elevation then I get either this route:
or this via a path:
So the problem is regarding the elevation spikes ( /smoothing ) like #2028 and I will close here.
zoom to coordinates and highlight on click for route hints, fixes gra…