Fix ambiguity in edge weights by using minimal weight

This commit is contained in:
Michael Krasnyk 2016-07-05 20:29:04 +02:00
parent b00b15ab98
commit e17b306265
No known key found for this signature in database
GPG Key ID: 3854C9454FE00649
2 changed files with 18 additions and 1 deletions

View File

@ -233,7 +233,7 @@ Feature: Basic Routing
| d | a | abcd,abcd | | d | a | abcd,abcd |
| a | m | aeim,aeim | | a | m | aeim,aeim |
| m | a | aeim,aeim | | m | a | aeim,aeim |
Scenario: Testbot - Triangle challenge Scenario: Testbot - Triangle challenge
Given the node map Given the node map
| | | | d | | | | | d |
@ -251,3 +251,18 @@ Feature: Basic Routing
| from | to | route | | from | to | route |
| d | c | de,ce,ce | | d | c | de,ce,ce |
| e | d | de,de | | e | d | de,de |
Scenario: Ambiguous edge weights - Use minimal edge weight
Given the node map
| a | b |
And the ways
| nodes | highway | name |
| ab | tertiary | |
| ab | primary | |
| ab | secondary | |
When I route I should get
| from | to | route | time |
| a | b | , | 10s |
| b | a | , | 10s |

View File

@ -453,11 +453,13 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state)
all_edges_list[i].result.weight < min_forward_weight) all_edges_list[i].result.weight < min_forward_weight)
{ {
min_forward_idx = i; min_forward_idx = i;
min_forward_weight = all_edges_list[i].result.weight;
} }
if (all_edges_list[i].result.backward && if (all_edges_list[i].result.backward &&
all_edges_list[i].result.weight < min_backward_weight) all_edges_list[i].result.weight < min_backward_weight)
{ {
min_backward_idx = i; min_backward_idx = i;
min_backward_weight = all_edges_list[i].result.weight;
} }
// this also increments the outer loop counter! // this also increments the outer loop counter!