Skip to content

maxspeed:forward and maxspeed:backward evaluates to the slower speed of both #2662

Description

@MaX-Lo

If different speeds apply for each direction on a way, OSM suggests using
maxspeed:forward for the speed in geometry direction and maxspeed:backward for the opposite direction.
(https://wiki.openstreetmap.org/wiki/Key:maxspeed#Driving_direction)

When setting both forward, and backward speed graphhopper appears to be using always the lower speed for both directions.
E.g. maxspeed:forward is 30 and maxspeed:backward is 5 -> resulting speed for both directions is 5.

From my understanding detailed information of speeds per direction are lost that way. Would be glad if someone could validate if this is the intended behaviour or I'm misunderstanding something. :)

protected static double getMaxSpeed(ReaderWay way) {
double maxSpeed = OSMValueExtractor.stringToKmh(way.getTag("maxspeed"));
double fwdSpeed = OSMValueExtractor.stringToKmh(way.getTag("maxspeed:forward"));
if (isValidSpeed(fwdSpeed) && (!isValidSpeed(maxSpeed) || fwdSpeed < maxSpeed))
maxSpeed = fwdSpeed;
double backSpeed = OSMValueExtractor.stringToKmh(way.getTag("maxspeed:backward"));
if (isValidSpeed(backSpeed) && (!isValidSpeed(maxSpeed) || backSpeed < maxSpeed))
maxSpeed = backSpeed;
return maxSpeed;
}

Activity

  1. otbutz commented on Sep 26, 2022

    @otbutz
    Contributor

    Any source for the OSM suggestion?

    The current logic will always use the lowest valid maxspeed value.

    Edit: misread your post. Forward/backward maxspeed distinction is obvious.

  2. otbutz commented on Oct 7, 2022

    @otbutz
    Contributor

    It appears that we don't fully support speed for different directions.

    CarTagParser.applyMaxSpeed() internally uses the lowest maxspeed. The result is simply duplicated if the EncodedValue supports two directions:

    // get assumed speed from highway type
    double speed = getSpeed(way);
    speed = applyMaxSpeed(way, speed);
    speed = applyBadSurfaceSpeed(way, speed);
    setSpeed(false, edgeFlags, speed);
    if (avgSpeedEnc.isStoreTwoDirections())
    setSpeed(true, edgeFlags, speed);

  3. karussell commented on Oct 7, 2022

    @karussell
    Member

    Yes, we should get rid of the maximum handling in the CarTagParser and use the max speed value from the encoded value where we support two values for both directions and then combine them in a custom model.

  4. added this to the 7.0 milestone on Jan 18, 2023
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions