Skip to content

Exception if speed is 0 but valid access flags and using shortest path algo. #242

Open

Description

@karussell

If a speed of 0 is assigned without setting the proper access flags to the edge, then a shortest path is still taken through this edge (although 'blocked') and leading to negativ millis variable in Path object which causes an exception.

java.lang.RuntimeException: Time was negative. Please report as bug and include:...
at com.graphhopper.GraphHopper.getPaths(GraphHopper.java:885)

Activity

  1. changed the title [-]Shortest path[/-] [+]Exception if speed is 0 but valid access flags. Only problem for shortest path.[/+] on Jul 31, 2014
  2. added this to the 0.3 milestone on Jul 31, 2014
  3. modified the milestones: 0.4, 0.3 on Oct 25, 2014
  4. karussell commented on Jan 14, 2015

    @karussell
    MemberAuthor

    As this is a usage problem and shortest path weighting really should not need to read the speeds, we just report this issue in more detail when this happens in Path.calcMillis

  5. changed the title [-]Exception if speed is 0 but valid access flags. Only problem for shortest path.[/-] [+]Exception if speed is 0 but valid access flags and using shortest path algo.[/+] on Jan 14, 2015
  6. added a commit that references this issue on Feb 4, 2017
  7. easbar commented on Nov 9, 2022

    @easbar
    Member

    I just ran into this again: This road https://www.openstreetmap.org/way/876442097 has a maxspeed=5 tag, so in CarTagParser we assign a speed of 0 km/h with the default speed bits configuration. This means that VehicleTagParser#setSpeed sets the access flag to false (but only for one direction?!). But directly afterwards in CarTagParser we set the access to true again, because of the oneway=yes tag.

    I then got this exception when I used the shortest weighting:

    Speed cannot be 0 for unblocked edge, use access properties to mark edge blocked! Should only occur for shortest path calculation. See #242.
    
    • a road tagged as maxspeed=5 should not be blocked for cars with the default configuration (?)
    • if speed_two_directions=false and the speed is so small that we decide to set the access to false we should do this for both directions?!
    • obviously we should not set the access back to true just because there is a oneway tag (after we decided it shall be blocked because of the low speed?)
    • a setSpeed method should not set access
    • speeds and access flags should not be intermixed in the first place?!
  8. reopened this on Nov 9, 2022
  9. karussell commented on Nov 9, 2022

    @karussell
    MemberAuthor

    speeds and access flags should not be intermixed in the first place?!

    Yeah, definitely a very important issue!

    But how can it still happen that we use the edge if speed is 0 (if access is true)?
    Because the case speed==0 is already handled in FastestWeighting and CustomWeighting.

    a road tagged as maxspeed=5 should not be blocked for cars with the default configuration (?)

    Yes. We could relax the current condition a bit and use <getSmallestNonZeroValue/2 instead of <getSmallestNonZeroValue like we did before? 3b67e2d

  10. otbutz commented on Nov 9, 2022

    @otbutz
    Contributor

    @easbar mentioned the shortest weighting. Maybe it's still unpatched for that.

  11. easbar commented on Nov 9, 2022

    @easbar
    Member

    Yes. We could relax the current condition a bit a

    Yes, or even just round up?

    @easbar mentioned the shortest weighting. Maybe it's still unpatched for that.

    Yes, it only happened with the shortest weighting, but I did not inspect this further.

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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions