Repository navigation
Closed
Description
When running random tests for #1581 the following error came up, see the modified test here:
cf65bb7
java.lang.IllegalStateException: Calculating time should not require to read speed from edge in wrong direction. (3 - 3) (49.400074021519885,9.700012051314385), (49.400074021519885,9.700012051314385) 0.0 Reverse:true, fwd:true, bwd:false
at com.graphhopper.routing.weighting.AbstractWeighting.calcMillis(AbstractWeighting.java:53)
at com.graphhopper.routing.weighting.FastestWeighting.calcMillis(FastestWeighting.java:83)
at com.graphhopper.routing.ch.PreparationWeighting.calcMillis(PreparationWeighting.java:57)
at com.graphhopper.routing.ch.Path4CH.expandEdge(Path4CH.java:53)
at com.graphhopper.routing.ch.Path4CH.expandSkippedEdges(Path4CH.java:72)
at com.graphhopper.routing.ch.Path4CH.expandEdge(Path4CH.java:57)
at com.graphhopper.routing.ch.Path4CH.processEdge(Path4CH.java:47)
at com.graphhopper.routing.PathBidirRef.extract(PathBidirRef.java:79)
at com.graphhopper.routing.AbstractBidirAlgo.extractPath(AbstractBidirAlgo.java:297)
at com.graphhopper.routing.AbstractBidirAlgo.calcPath(AbstractBidirAlgo.java:95)
at com.graphhopper.routing.RandomCHRoutingTest.issue1574_random(RandomCHRoutingTest.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]Rare reading speed in wrong direction error on loop edge.[/-][+]'Rare reading speed in wrong direction error' on loop edge.[/+]karussell commentedon Mar 28, 2019
The problem is that the speed is set to zero and that this is decoupled from the access bits. See e.g. #367
I have thought this through multiple times and wanted to create a special SpeedAccessEncodedValue object that automatically sets the access bits based on the speed. But this is a bit tricky and additionally it would not help when we calculate the speed and access limits on demand. So e.g. the estimated speed could be well over 10km/h and still the truck does not fit through the bridge.
easbar commentedon Mar 28, 2019
Where is the speed set to zero ? Or do you mean the distance (which is 0 at the point the exception is thrown in my debugger).
karussell commentedon Mar 28, 2019
I was too hasty as I saw the "0" in the exception, but you are right that the distance==0.
Still this issue appears because speed and access values are not in sync. So everytime you set the speed to 0 (or any other property that will lead to weight==infinity) you have to set the edge inaccessible explicitly.
This is also a conceptual problem that we use "static access properties" instead of "dynamic weighting". See e.g. the EdgeFilter in QueryGraph where it could happen that the weight==infinity for an allowed edge ("access-wise"). See #729
[-]'Rare reading speed in wrong direction error' on loop edge.[/-][+]Rare 'reading speed in wrong direction error' on loop edge.[/+]easbar commentedon Apr 1, 2019
Ok I see, but in this case the speed is not zero:

It's a zero distance (and zero weight, because of fastest weighting) (non-shortcut) one-way loop edge that is read in the wrong direction during path extraction.
A possible explanation is that a zero distance loop is usually an error in OSM data and probably almost never tagged with
one_way, but if we use a zero distance loop with only one direction we get the above error.easbar commentedon Apr 1, 2019
Related to: #1525, #1247, #1355, #1531
[-]Rare 'reading speed in wrong direction error' on loop edge.[/-][+]Rare 'reading speed in wrong direction error' on one-way zero distance loop edge.[/+]karussell commentedon Apr 1, 2019
I just stumbled also over this still open issue #1234
karussell commentedon Apr 1, 2019
But we avoid distance==0 in the OSM import: https://github.com/graphhopper/graphhopper/blob/master/reader-osm/src/main/java/com/graphhopper/reader/osm/OSMReader.java#L740
easbar commentedon Apr 1, 2019
Yes, and also loops as just came to my mind again: #1531
easbar commentedon Apr 1, 2019
I still might have a look what is going on here, not sure if we have to rely on the import or if this can be fixed easily.
easbar commentedon Apr 2, 2019
So it turned out there was in fact a problem (I only realized I had fixed it after I had fixed it :))
When there was a loop at a node we were contracting like at node 0 here:
we introduced a shortcut from 0 to 1 where the first skipped edge was the loop and this could cause the read in the wrong direction error later when unpacking the shortcut. It did not matter whether the distance was 0 or not, but unfortunately
GHUtility#buildRandomGraphalways uses distance 0 for loop edges.Fixed in b2ba5bd.