Repository navigation
Improve instructions - #955
Conversation
|
So the current state is not too bad, IMHO. I tested a lot of random bike routes and compared the generated instructions with the instructions I would have expected according to the map. I'd say that I agree with > 95%. Are there any examples that I should try? I have tested the examples provided #94, but most of them still behave the same, as they were not intended to be improved in this PR. We should definitely find a solution to the above mentioned NEW issue. Not sure if performance is an issue here? Haven't measured my solution, but it obviously needs more resources, than the old solution. It does not feel slower than before (...). |
|
I updated this PR to show Continue instructions if the situation might not be clear. Sometimes they happen too frequent, but haven't found a better way to filter them. |
…verted before merging
…verted before merging
…tions # Conflicts: # core/src/test/java/com/graphhopper/routing/PathTest.java
|
I really like the debugging view where all turns have a marker - nice :) ! Also I think the improvement is indeed there and good and will now look into more examples. |
|
@karussell Thanks for the review. I updated this PR. In order to fix your necessary improvements I had to introduce a new concept: "keep right|left". In theory this should recognize forks, and tell the user if (s)he should go left or right at the fork. This fixes most issues, especially for motorways. Until all clients support the new sign for keeps we could also change the keeps to slight_right|left. However, this fails sometimes. To make it better I think that I would need the highway type. For example we still miss the right turn here: http://localhost:8989/?point=49.398826%2C11.197751&point=49.39789%2C11.197729&vehicle=car
This example is very interesting: http://localhost:8989/?point=49.912877%2C11.568802&point=49.911965%2C11.56899&vehicle=foot Most importantly, why does it show turn right, instead of continue? I debugged a bit. The orientation is calculated for the following points with the following orientation: The second orientation is calculated for two points that are almost identical. Not sure if GH creates a very small edge in this case? Due to this GH thinks that there is a right turn, with two possible turns, so the right turn is displayed.
Probably the bike instruction was due to an annotation? Should be fixed with my new commit anyway.
Haven't touched roundabouts in this PR. Maybe we should create a new issue for this?
That's true, but I am not sure if this would be fixable. You could also walk straight ahead, so you are shown the instruction to turn right onto this foot path. From a data perspective this turn instruction is correct. This might be misleading for a user though.
How would you fix that? I think this is the typical example where people turn wrong. GPS is not exact enough, so you have to study the map closely.
Shouldn't this be the job of the navigation engine? I think we show the correct turns here. A navigation engine might check if instructions are close together and merge them like: "turn left and after 10 m turn right".
That's a good idea. Maybe put this into a different PR as well? |
| // Debug Turn Instructions more easily | ||
| L.marker([lngLat[1], lngLat[0]], { | ||
| draggable: true | ||
| }).addTo(mapLayer.getRoutingLayer()).bindPopup(title); |
There was a problem hiding this comment.
Can we always enable turn instruction debugging via an URL parameter debug_instruction=true or something? Also printing a marker for every instruction is really helpful (but not for the normal public audience of course ;))
There was a problem hiding this comment.
Good idea, added that feature.
|
I've just realized that the improved instructions fail for the DataFlagEncoder. The improved instructions use the getSpeed method, which is not implemented for the DataFlagEncoder. What should we do about that? |
|
I updated this PR to show the instructions nodes only when passing |
Probably it is time to refactor something else before this change. Because getSpeed is not something the FlagEncoder can know and only a configured Weighting does. Hmmh. |
I think we need a different sort of logic for the DataFlagEncoder anyways, as it contains the HighwayType and so on. So I could try and see if I can create some special code block for the DataFlagEncoder? Not very nice but probably the best choice right now? |
|
I updated this PR. I added a fix for the DataFlagEncoder. We might have slightly more instructions for the DataFlagEncoder compared to the other Encoders. We might show instructions where they are not necessary, but we don't ignore any instructions. The speed is currently only used to omit instructions that seem to be not relevant. In a future PR, we should improve the instructions for the DataFlagEncoder using also the highway tag and maybe even calculate the actual speed for every edge. I will open a separate issue for this. The good thing is we don't have to defer this PR and can use the improved instructions. |
| while (edgeIter.next()) { | ||
| tmpSpeed = encoder.getSpeed(edgeIter.getFlags()); | ||
| if (encoder instanceof DataFlagEncoder) { | ||
| tmpSpeed = ((DataFlagEncoder) encoder).getMaxspeed(edgeIter, 0, false); |
There was a problem hiding this comment.
as we have the weighting in the Path class available, would it be somehow possible to use it here instead? E.g. edgeIter.getDistance/calcMillis?
There was a problem hiding this comment.
Might be, yes. I am a bit afraid of rounding issues, as I am comparing these values, but sure, I can try that. OTOH I think we need a different logic for the DataFlagEncoder. We need to consider the highway tag and speed becomes rather unimportant (maybe we only need to check speed with a low priority, whereas for the other encoders speed is important for the instruction generation.
|
Currently problematic remains this Route: But the current version of GH has the same issue, so this is no regression: I think we should be aware of these things and try to improve them, but from a data point of view this is hard to solve. With highway tags this would be easy to solve. However, this need a different logic, so I think we should do this separately for the DataFlagEncoder. After some consideration I think we should do the DataFlagEncoder Optimization in a completely different branch. The DataFlagEncoder instructions are improved by this PR, but not as much as the other encoders. Things I've seen during testing:
Something I have changed is to return Continues instead of Keeps, if we are going pretty straight and the other road is at least slightly bend. This removes keeps, that could be misunderstood, if there is a turn close by. When we merge this, we should also get images for the keeps in the front-end. |
|
To avoid breaking the existing clients can we also use keep_left=slight_left just until we have released the more tolerant js&java clients for ~3 months? |
Yes sure, not a problem. |
|
I just changed the code a bit. If there was an annotation, we would not have used the improved instructions, but just showed the old instructions. With the old code, this would have generated the following instruction "Continue, small way, unpaved", now we generate this: "Turn slight right, small way, unpaved", which is more accurate. |
|
👍 |
This PR intents to improve the current turn instructions. (#94)
Manly this PR tries to solve the following issues:
I made a couple of assumptions and changes the way I would like to receive turn instructions. This is very subjective, some people like more, some people like less.
The basic function is:
Currently, a lot of tests are failing. I can fix all the failing ITs once, we decided if we want the current behavior like that or not.
My personal opinion on the state of this PR:
It is better as the current approach in most situations. However, there are thousands of edge cases we need to consider¹. For example look at the TODOs, there are cases that just happens very infrequent, but they happen and with some I feel like there is no good solution, without making other cases worse. It mostly happens in dense cities with a lot of streets around. Bicycle and Non-City instructions are pretty good IMHO (haven't found bigger issues yet).
Feedback from others checking the turn instructions for their area would be highly appreciated.
TODO:
Shows an unnecessary continue http://localhost:8989/?point=48.004367%2C8.137822&point=48.003878%2C8.137844
Shows an unnecessary continue on trunks, motorways. Depending on the motorway speed this happens quite frequently.
When leaving a street via a CONTINUE instruction. We should check for continue instructions if it seems that we are leaving a street, if yes, show the CONTINUE instruction, or maybe create a special instruction?
When turning onto a one-way turn instructions are omitted, as it is the only possible turn. In general this is ok, but when there are two one-ways (e.G. highways) and you need to cross the first one and then turn left on the second, the turn instruction is omitted
In this situation, we could show a left turn, not sure: http://localhost:8989/?point=48.769739%2C9.245929&point=48.769707%2C9.245451
Just found the worst case situation for the junction analyzer. Two edges, one is the edge we are turning onto, the other is just a random edge, but both starting and ending at the same node. Therefore, the other edge is not counted as possible turn. See http://localhost:8989/?point=48.815822%2C9.151365&point=48.815409%2C9.152888. The issue is created by this edge http://www.openstreetmap.org/way/7975515.
Revert the tmp js change. This makes debugging instructions a better experience, but would probably annoy regular users.
¹: Thousands of edge cases sounds like a good case for deep learning.