From e17b3062653fc5a0b6120262d6d45b6c50bfa661 Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Tue, 5 Jul 2016 20:29:04 +0200 Subject: [PATCH] Fix ambiguity in edge weights by using minimal weight --- features/testbot/basic.feature | 17 ++++++++++++++++- src/extractor/extraction_containers.cpp | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/features/testbot/basic.feature b/features/testbot/basic.feature index 03b48929d..3663d37aa 100644 --- a/features/testbot/basic.feature +++ b/features/testbot/basic.feature @@ -233,7 +233,7 @@ Feature: Basic Routing | d | a | abcd,abcd | | a | m | aeim,aeim | | m | a | aeim,aeim | - + Scenario: Testbot - Triangle challenge Given the node map | | | | d | @@ -251,3 +251,18 @@ Feature: Basic Routing | from | to | route | | d | c | de,ce,ce | | 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 | diff --git a/src/extractor/extraction_containers.cpp b/src/extractor/extraction_containers.cpp index d154304df..c506aa59d 100644 --- a/src/extractor/extraction_containers.cpp +++ b/src/extractor/extraction_containers.cpp @@ -453,11 +453,13 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state) all_edges_list[i].result.weight < min_forward_weight) { min_forward_idx = i; + min_forward_weight = all_edges_list[i].result.weight; } if (all_edges_list[i].result.backward && all_edges_list[i].result.weight < min_backward_weight) { min_backward_idx = i; + min_backward_weight = all_edges_list[i].result.weight; } // this also increments the outer loop counter!