Skip to content

Negative route durations #5967

@mjjbell

Description

@mjjbell

Through the use of negative turn penalties, it's possible to return steps, legs or even entire routes that have negative durations.

    Background: 
        Given the node map
            """
            a   b   c   d
            """

        And the nodes
            | node | id |
            | a    | 1  |
            | b    | 2  |
            | c    | 3  |
            | d    | 4  |

        And the ways
            | nodes | highway |
            | ab    | primary |
            | bc    | primary |
            | bc    | primary |
            | cd    | primary |
        And the profile "testbot"


    Scenario: negative route
        Given the turn penalty file
            """
            2,3,4,-70,0
            """
        And the contract extra arguments "--turn-penalty-file {penalties_file}"
        And the customize extra arguments "--turn-penalty-file {penalties_file}"

        When I route I should get
            | from | to | route       | time    |
            | a    | d  | ab,bc,cd,cd | -10     |

I think this should be tightened up. I can't think of a use-case where a negative duration in the result would be desired.

Current implementation

Some observations about the current implementation:

Proposed Fix

My suggestion is to implement the same negative penalty clamping for duration as is done for weight when performing traffic updates. This will prevent steps, legs and routes from having negative duration. It will also provide consistency with the duration clamping that already occurs on the first route edge.

Related

Negative turn penalty discussion - #3683

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions