Skip to content

Use max_speed EV for the AbstractFlagEncoder #2266

Closed as not planned
Closed as not planned

Description

@otbutz

I'm currently testing to switch the AbstractFlagEncoder to use the max_speed encoded value and have already a working prototype. The remaining problem seems to be related to how we handle spatial rules and fallback values.

Let's take the following route which is part of our unittests as an example:

grafik

https://graphhopper.com/maps/?point=49.995905%2C11.547918&point=50.004871%2C11.517191vehicle=car&weighting=fastest&elevation=true

The route changes if the encoded max_speed values in conjunction with spatial rules are used:

grafik

The detour seems to be caused by the high fallback values of the spatial rule which assumes 100kmh for unclassified/residential. This is higher than the tagged speedlimit of 70kmh for the B85 and causes the routing to bypass it.

I can lower the limits in the GermanySpatialRule so that they fit the defaultSpeedMap values of the CarFlagEncoder but i'm not sure if that's the best course of action.

Activity

  1. boldtrn commented on Mar 25, 2021

    @boldtrn
    Member

    I am not 100% sure what you are doing, but there are two different values now: max_speed and average_speed. For the routing, I would use average_speed, not sure if you are using max_speed there?

  2. otbutz commented on Mar 25, 2021

    @otbutz
    ContributorAuthor

    The AbstractFlagEncoder currently does the following as part of its avg speed calculation:

    protected 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;
    }

    So it's basically doing the same as the OSMMaxSpeedParser but doesn't take SpatialRules into account.

    public IntsRef handleWayTags(IntsRef edgeFlags, ReaderWay way, EncodingManager.Access accept) {
    if (accept.canSkip())
    return edgeFlags;
    if (!accept.isFerry()) {
    // get assumed speed from highway type
    double speed = getSpeed(way);
    speed = applyMaxSpeed(way, speed);
    speed = applyBadSurfaceSpeed(way, speed);
    setSpeed(false, edgeFlags, speed);

    getSpeed retrieves the default speed for the FlagEncoder based on the road class, applyMaxSpeed retrieves the maxspeed for the way and falls back to former default speed if no valid value could be found. And finally the speed is capped by applyBadSurfaceSpeed based on the surface of the way.

  3. otbutz commented on Mar 25, 2021

    @otbutz
    ContributorAuthor

    So we're parsing the maximum speed for each way in the OSMMaxSpeedParser and again for each registered FlagEncoder. And on top of that SpatialRules are not applied.

  4. otbutz commented on Mar 25, 2021

    @otbutz
    ContributorAuthor

    Lowering the fallback speeds for Germany yields the expected result:

    grafik

  5. karussell commented on May 31, 2023

    @karussell
    Member

    I don't think this will be possible. In #2810 I will feed max_speed with a precise value based on the country and urban_density but this will be available after the import only. So I think the best way to make this happen is in a custom model (?)

  6. otbutz commented on May 31, 2023

    @otbutz
    ContributorAuthor

    #2810 is the better approach 😉

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