Skip to content

maxspeed=0.5 on a way triggers exception when using bicycle profile #3070

Closed

Description

@ratrun

Describe the bug
I found a spot where OSM contains ways tagged with maxspeed=0.5. This bad data triggers the following exception when using one of the bicycle profiles

java.lang.IllegalArgumentException: Speed was 0.5 but cannot be lower than 1.0

	at com.graphhopper.routing.util.parsers.AbstractAverageSpeedParser.setSpeed(AbstractAverageSpeedParser.java:42)
	at com.graphhopper.routing.util.parsers.BikeCommonAverageSpeedParser.handleWayTags(BikeCommonAverageSpeedParser.java:176)
	at com.graphhopper.routing.util.parsers.AbstractAverageSpeedParser.handleWayTags(AbstractAverageSpeedParser.java:54)
	at com.graphhopper.routing.util.OSMParsers.handleWayTags(OSMParsers.java:101)
	at com.graphhopper.routing.util.parsers.AbstractBikeTagParserTester.getSpeedFromFlags(AbstractBikeTagParserTester.java:103)
	at com.graphhopper.routing.util.parsers.BikeTagParserTest.testSmoothness(BikeTagParserTest.java:366)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

To Reproduce
Tag a way with tag maxspeed=0.5 and use a bicycle profile

Expected behavior
No exception

System Information

Latest master

Activity

  1. ratrun commented on Oct 17, 2024

    @ratrun
    ContributorAuthor

    I'm not sure if this change is the way to go:

        protected void setSpeed(boolean reverse, int edgeId, EdgeIntAccess edgeIntAccess, double speed) {
            if (speed < avgSpeedEnc.getSmallestNonZeroValue() / 2) {
                avgSpeedEnc.setDecimal(reverse, edgeId, edgeIntAccess, avgSpeedEnc.getSmallestNonZeroValue());
            } else {
                avgSpeedEnc.setDecimal(reverse, edgeId, edgeIntAccess, speed);
            }
        }
    
  2. added a commit that references this issue on Oct 27, 2024
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