Skip to content

Rare 'reading speed in wrong direction error' on one-way zero distance loop edge. #1583

Closed

Description

@easbar

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)

Activity

  1. changed the title [-]Rare reading speed in wrong direction error on loop edge.[/-] [+]'Rare reading speed in wrong direction error' on loop edge.[/+] on Mar 28, 2019
  2. karussell commented on Mar 28, 2019

    @karussell
    Member

    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.

  3. easbar commented on Mar 28, 2019

    @easbar
    MemberAuthor

    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).

  4. karussell commented on Mar 28, 2019

    @karussell
    Member

    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

  5. changed the title [-]'Rare reading speed in wrong direction error' on loop edge.[/-] [+]Rare 'reading speed in wrong direction error' on loop edge.[/+] on Mar 29, 2019
  6. easbar commented on Apr 1, 2019

    @easbar
    MemberAuthor

    Ok I see, but in this case the speed is not zero:
    image

    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.

  7. easbar commented on Apr 1, 2019

    @easbar
    MemberAuthor

    Related to: #1525, #1247, #1355, #1531

  8. changed the title [-]Rare 'reading speed in wrong direction error' on loop edge.[/-] [+]Rare 'reading speed in wrong direction error' on one-way zero distance loop edge.[/+] on Apr 1, 2019
  9. karussell commented on Apr 1, 2019

    @karussell
    Member

    I just stumbled also over this still open issue #1234

  10. karussell commented on Apr 1, 2019

    @karussell
    Member

    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

    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

  11. easbar commented on Apr 1, 2019

    @easbar
    MemberAuthor

    But we avoid distance==0 in the OSM import:

    Yes, and also loops as just came to my mind again: #1531

  12. easbar commented on Apr 1, 2019

    @easbar
    MemberAuthor

    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.

  13. easbar commented on Apr 2, 2019

    @easbar
    MemberAuthor

    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:

    0-1
    o
    

    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#buildRandomGraph always uses distance 0 for loop edges.
    Fixed in b2ba5bd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions