Repository navigation
Conversation
Conflicts: core/src/main/java/com/graphhopper/reader/OSMReaderHelperDoubleParse.java
Conflicts: core/src/main/java/com/graphhopper/GHRequest.java core/src/main/java/com/graphhopper/GraphHopper.java core/src/main/java/com/graphhopper/reader/OSMReader.java core/src/main/java/com/graphhopper/reader/OSMReaderHelper.java core/src/main/java/com/graphhopper/routing/AbstractRoutingAlgorithm.java core/src/main/java/com/graphhopper/routing/ch/PrepareContractionHierarchies.java core/src/main/java/com/graphhopper/routing/util/VehicleEncoder.java core/src/test/java/com/graphhopper/routing/AbstractRoutingAlgorithmTester.java
a turn restriction is around the meeting point.
Conflicts: core/src/main/java/com/graphhopper/reader/OSMReader.java core/src/main/java/com/graphhopper/routing/ch/PrepareContractionHierarchies.java
Conflicts: core/src/main/java/com/graphhopper/reader/OSMReaderHelper.java core/src/main/java/com/graphhopper/reader/OSMReaderHelperDoubleParse.java core/src/main/java/com/graphhopper/routing/util/AbstractFlagEncoder.java
Conflicts: core/src/main/java/com/graphhopper/GraphHopper.java core/src/main/java/com/graphhopper/reader/OSMReader.java core/src/main/java/com/graphhopper/reader/OSMReaderHelper.java core/src/main/java/com/graphhopper/routing/AbstractRoutingAlgorithm.java core/src/test/java/com/graphhopper/routing/DijkstraOneToManyTest.java
|
Thanks a lot! |
|
|
Hm ok, I will try to find out what's wrong.
Good choice.
There are no relations of type.restriction in the osm file. The import currently only add turn restrictions for this kind of relations.
Yes, this comment is a bit old. As I wrote above you need to decide before preparation if you want to consider turn restrictions or not, you can not change it later when requesting routes. |
Ah, ok. We'll need a file with this relations to avoid testing stuff from real world files every here and then. I'll see if I have time this evening
Ok |
There are two different errors in the resulting route:
|
Ah, I didn't spotted the roundabout problem! I'll see if we can fix that even without a
Hmmh, strange. Even without CH it didn't work for me (I'll try again this evening) |
|
I'm not allowed to push changes to this branch. Would you mind to give me permission to push changes to this branch or should I fork the branch and do pull requests? |
I gave you the permission. Please be careful as this is not limited to this branch only ;) ! |
|
nope, seems to be another issue.. :'( PS: It totally sucks to debug such things with OSM data :D |
Do you know the MiniGraphUI in the tools project? CH debugging is a bit harder even there. But still you could enable 'debug' and you see how the algorithm behave and you can also print the internal node indices etc. You could also print the exploration step by step with the help of your debugger (but only if you ensure that the window of your IDE and the MiniGraphUI do not overlap) |
|
Please see the newly added test GraphStorageTurnCostTest:testTurnCost this gives me: something went wrong: next entry would be the same |
Can't find this, did you push it? |
|
Alright, I pushed an initial version of the edge-based Dijkstra. Feel free to try it with your test. |
Thanks!
with me it is the same. I would like to push out 0.1 before I'll add more bigger features like this :/ The problem with turn restrictions is that they slow down everything, the preparation time will also suffer a lot and the algorithm will get more complex with it. So we'll have to take a lot of care when we add this. |
this is not a real limitation as even without turn restriction we do not support negative ids.
and can we somehow improve this? I mean, like in the paper, they say such turn restrictions are rather rare and they could implement some 'dynamic' behaviour. e.g. pushing such restricted nodes with all its associated edges + weights as only one entry to the queue. |
|
Well, I finally merged the master into pr/55. The build is green, but due to the API changes in the import and encoding mechanisms, I'm not sure if everything works as expected.
Yes, we totally could do that. However, if we want to include turn costs as well to make routes more realistic, this approach would not give any advantages, since each junction will be in relation with turn costs. I'm currently writing my master thesis and I need a routing algorithm which supports turn restrictions. The current state is sufficient for my needs; performance is not that important. Therefore, I won't go deeper into this topic because I have to concentrate on other things. However, I will try to answer incoming questions. So, everyone is invited to continue my work! Short summary of the current state of this issue:
PS: How do I add my last merge commit to this pull request? |
Ok, no problem.
I really welcome the work you did when merging and the work you've already done! I would like to merge it sooner than later. I'll have a look into this! Probably we should only integrate edge based algos to keep node-based algorithms simpler? Or which algorithm classes are you using and trying out for your work?
Hmmh, strange. Normally this appears automatically if you push the changes. Did you push to khuebner/master? BTW: Are you sure you updated your master before? As the merge pr/55 does not look to be aligned with the latest master. But nevermind, if you don't have the time then I'll try to get it up to date. BTW: Also are you willing to contribute your work under Apache License and with the same header snippet? |
|
Is there anything we can do to help getting this feature in, or has this branch been abandoned? |
|
It is on the road map to integrate this but other things are still more important. The first step could be to make it compile against master. Afterwards additional tests needs to be added as well as making contraction hierarchies working. |
|
@karussell I spent a day or so merging the latest changes from master back to the work @khuebner has done here: Now, apart from being a Java dev and somewhat experienced with merging, I have very little idea of what I was doing there in regards to business logic. Perhaps either of you could have a look and see what you think. |
|
Thanks for this work! Wow, this is a massive edit :) I think @khuebner was also in the process of doing this. Maybe he can have a look and decide wether it is worth to merge or too risky and just grab the important pieces (algorithm, relation parsing and graphstorage changes) and tests. What I don't like is that turn costs are so invasive like with Another major problem is that we have QueryGraph which creates virtual nodes and edges per request, where turn restrictions could be necessary too :(
setting flags is done ala |
@karussell I'm afraid those things are still a bit over my head, and I lack the domain understanding here to do anything useful beyond pure refactorings just to make the code look nicer, which is very hard with poor test coverage and not-working code. I'll try running some tests and fire it up tomorrow to see whether it's functional at all. |
That would be good. Are the other tests passing? |
Don't know yet :) |
|
I fixed a couple of obvious errors in tfnico/graphhopper@544410d Here are the current test results: Failed tests:
GraphHopperTest.testFootAndCar:111 expected:<2> but was:<3>
GraphHopperTest.testLoadOSM:62 null
OSMReaderTurnCostsTest.testImportTurnRestrictions:54 expected:<1.07374182E9> but was:<0.0>
AStarBidirectionTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_CarPath_turnRestrictions:208 expected:<{0, 1, 5, 3}> but was:<{0, 1, 5, 8, 3}>
AStarBidirectionTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_CarPath_ignoreTurnRestrictions:219 distance:18000.0, edges:4 expected:<5760> but was:<18000>
AStarBidirectionTest>AbstractRoutingAlgorithmTester.testCalcIfEmptyWay:270 distance:24.0, edges:6 expected:<0> but was:<7>
AStarBidirectionTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_FootPath_noTurnRestrictions:228 distance:16000.0, edges:4 expected:<11520> but was:<16000>
AStarTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_CarPath_turnRestrictions:208 expected:<{0, 1, 5, 3}> but was:<{0, 1, 5, 8, 3}>
AStarTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_CarPath_ignoreTurnRestrictions:219 distance:18000.0, edges:4 expected:<5760> but was:<2147483647>
AStarTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_FootPath_noTurnRestrictions:228 distance:16000.0, edges:4 expected:<11520> but was:<2147483647>
DijkstraBidirectionCHTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_CarPath_turnRestrictions:208 expected:<{0, 1, 5, 3}> but was:<{0, 1, 5, 8, 3}>
DijkstraBidirectionCHTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_FootPath_noTurnRestrictions:228 distance:16000.0, edges:4 expected:<11520> but was:<16000>
DijkstraBidirectionRefTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_CarPath_turnRestrictions:208 expected:<{0, 1, 5, 3}> but was:<{0, 1, 5, 8, 3}>
DijkstraBidirectionRefTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_CarPath_ignoreTurnRestrictions:219 distance:18000.0, edges:4 expected:<5760> but was:<18000>
DijkstraBidirectionRefTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_FootPath_noTurnRestrictions:228 distance:16000.0, edges:4 expected:<11520> but was:<16000>
DijkstraBidirectionTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_CarPath_turnRestrictions:208 expected:<{0, 1, 5, 3}> but was:<{0, 1, 5, 8, 3}>
DijkstraBidirectionTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_CarPath_ignoreTurnRestrictions:219 distance:18000.0, edges:4 expected:<5760> but was:<18000>
DijkstraBidirectionTest>AbstractRoutingAlgorithmTester.testCalcIfEmptyWay:270 distance:24.0, edges:6 expected:<0> but was:<7>
DijkstraBidirectionTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_FootPath_noTurnRestrictions:228 distance:16000.0, edges:4 expected:<11520> but was:<16000>
DijkstraOneToManyTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_CarPath_turnRestrictions:208 expected:<{0, 1, 5, 3}> but was:<{0, 1, 5, 8, 3}>
DijkstraOneToManyTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_CarPath_ignoreTurnRestrictions:219 distance:18000.0, edges:4 expected:<5760> but was:<2147483647>
DijkstraOneToManyTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_FootPath_noTurnRestrictions:228 distance:16000.0, edges:4 expected:<11520> but was:<2147483647>
DijkstraTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_CarPath_turnRestrictions:208 expected:<{0, 1, 5, 3}> but was:<{0, 1, 5, 8, 3}>
DijkstraTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_CarPath_ignoreTurnRestrictions:219 distance:18000.0, edges:4 expected:<5760> but was:<2147483647>
DijkstraTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_FootPath_noTurnRestrictions:228 distance:16000.0, edges:4 expected:<11520> but was:<2147483647>
EdgeAStarTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_CarPath_turnRestrictions:208 expected:<{0, 1, 5, 3}> but was:<{0, 1, 5, 8, 3}>
EdgeAStarTest>AbstractRoutingAlgorithmTester.testViaEdges_WithCoordinates:629 expected:<{9, 1, 2, 8}> but was:<{}>
EdgeAStarTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_CarPath_ignoreTurnRestrictions:219 distance:18000.0, edges:4 expected:<5760> but was:<2147483647>
EdgeAStarTest>AbstractRoutingAlgorithmTester.testViaEdges_FromEqualsTo:620 expected:<{8, 9}> but was:<{}>
EdgeAStarTest>AbstractRoutingAlgorithmTester.testViaEdges_SpecialCases:654 expected:<{6, 1, 2, 3, 5}> but was:<{}>
EdgeAStarTest>AbstractRoutingAlgorithmTester.testViaEdges_BiGraph:605 distance:0.0, edges:0 expected:<{10, 7, 6, 8, 3, 9}> but was:<{}>
EdgeAStarTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_FootPath_noTurnRestrictions:228 distance:16000.0, edges:4 expected:<11520> but was:<2147483647>
EdgeDijkstraBidirectionRefTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_CarPath_turnRestrictions:208 expected:<{0, 1, 5, 3}> but was:<{0, 1, 5, 8, 3}>
EdgeDijkstraBidirectionRefTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_CarPath_ignoreTurnRestrictions:219 distance:18000.0, edges:4 expected:<5760> but was:<18000>
EdgeDijkstraBidirectionRefTest>AbstractRoutingAlgorithmTester.testViaEdges_FromEqualsTo:620 expected:<{8, 9}> but was:<{8, 9, 1, 4, 0, 8, 9}>
EdgeDijkstraBidirectionRefTest>AbstractRoutingAlgorithmTester.testViaEdges_SpecialCases:659 expected:<{5, 6}> but was:<{5, 6, 3, 4, 0, 1, 2, 5, 6}>
EdgeDijkstraBidirectionRefTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_FootPath_noTurnRestrictions:228 distance:16000.0, edges:4 expected:<11520> but was:<16000>
EdgeDijkstraTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_CarPath_turnRestrictions:208 expected:<{0, 1, 5, 3}> but was:<{0, 1, 5, 8, 3}>
EdgeDijkstraTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_CarPath_ignoreTurnRestrictions:219 distance:18000.0, edges:4 expected:<5760> but was:<2147483647>
EdgeDijkstraTest>AbstractRoutingAlgorithmTester.testCalcWithTurnRestrictions_FootPath_noTurnRestrictions:228 distance:16000.0, edges:4 expected:<11520> but was:<2147483647>
DefaultTurnCostsCalcTest.turnCostCalc_shortestRoute_carEncoder:155 expected:<0.0> but was:<100.0>
Tests in error:
GraphHopperTest.testPrepareOnly:238 IllegalArgument Encoder for car not foun...
GraphHopperTest.testFootOnly:221 IllegalArgument Encoder for car not found.
EdgeDijkstraTest>AbstractRoutingAlgorithmTester.testNoPathFound:278 NullPointer
Tests run: 752, Failures: 41, Errors: 3, Skipped: 0
|
|
Hey guys. I'm totally deep into merging the master into this branch, but I'm not able to continue before weekend. I'll take a look at what @tfnico has done so far, and I would prefer to take care of the edge-based algorithms by myself (i.e. all algorithms which extend AbstractEdgeBasedRoutingAlgorithm). For all the other stuff anyone is welcomed to help me resolving conflicts. Furthermore, I would like to remove any turn-restriction support out of the existing node-based routing algorithms, since it is just faulty to consider turn-restrictions in those classic algorithms. |
|
FYI: I merged the master into pr/55 (5 tests still fail) |
|
Thanks a lot! I'll have a look into it. One question: why could one disable the turn cost in GraphStorageTurnCosts?
As there are no mixin the only possibility in Java would be to define an interface which can be called within GraphHopperStorage and is a composition of e.g. turn and shortcut support. But I'll have to sort this out after merge.
Yes, let us make turn restriction support for normal algos working first adding more test. Then we do turn stuff for CH, then making everything nice & fast. |
|
I think it will be better to "rebuild" this whole thing from scratch instead of trying to merge this monster. We should do this step by step, for each step one pull request, which should make it a lot easier to review and merge:
I have done those things already and they also are part of this monster commit, but I would prefer to make tiny commits step by step onto the master. Further features, like CH, can be done later. |
|
For step 2 and 3 I think #132 is very handy which I integrate now, but go ahead as merging should be easy then. |
|
Hello. Thanks |
|
Hi, this feature is still under development. We've splitted this pull request into smaller pieces: #133, #134, #135 , #158 |
|
Hello, |
Use bash for map-matching.sh
…-overlays graphhopper#19 map overlays

Here's my attempt to let graphhopper support turn costs/restrictions (turn cost = time a turn would cost, turn restriction = infinite turn cost, turn is prohibited).
At the moment only simple turn restrictions will be imported. You can enable turn restriction support by
GraphHopper.enableTurnCosts()and you need to re-import your osm files. If you want to use turn restrictions together with contraction hierarchies you must decide on preparation time if and which kind of turn cost calculation you want to use. Once the graph has been prepared for contraction hierarchies you cannot switch to another turn cost calculation. This behavior should be familiar since you need to decide on preparation time as well which EdgePropertyEncoder and which WeightCalculation you want to use.Turn costs are stored in a separate storage. For each turn cost entry the edge id from which the turn goes, the edge id to which the turn goes and the costs of the specific turn is stored. The costs are encoded by TurnCostEncoder, which allows to store separate costs for car and bike in one integer value. When searching for shortest routes only restrictions will be considered, when searching for fastest routes restrictions AND turn costs will be considered. For pedestrians no turn costs or restrictions will be considered.
Feel to try it out. I will add some more details to my implementation when I have a bit more time, maybe tomorrow.