From 70bb0829739bab0a49ce3bc2f2e8ae079c03b1b7 Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Thu, 3 Sep 2015 10:40:16 +0200 Subject: [PATCH] Fix endless loop --- data_structures/hidden_markov_model.hpp | 1 + routing_algorithms/map_matching.hpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/data_structures/hidden_markov_model.hpp b/data_structures/hidden_markov_model.hpp index 60738a561..15aa35b8b 100644 --- a/data_structures/hidden_markov_model.hpp +++ b/data_structures/hidden_markov_model.hpp @@ -96,6 +96,7 @@ template struct HiddenMarkovModel path_lengths.resize(candidates_list.size()); suspicious.resize(candidates_list.size()); pruned.resize(candidates_list.size()); + breakage.resize(candidates_list.size()); for (const auto i : osrm::irange(0u, candidates_list.size())) { const auto& num_candidates = candidates_list[i].size(); diff --git a/routing_algorithms/map_matching.hpp b/routing_algorithms/map_matching.hpp index 0993b2eef..58b0ad1a8 100644 --- a/routing_algorithms/map_matching.hpp +++ b/routing_algorithms/map_matching.hpp @@ -301,14 +301,17 @@ class MapMatching final : public BasicRoutingInterface= sub_matching_begin && model.breakage[parent_timestamp_index]) { --parent_timestamp_index; } + while (sub_matching_begin < sub_matching_end && + model.breakage[sub_matching_begin]) + { + ++sub_matching_begin; + } // matchings that only consist of one candidate are invalid if (parent_timestamp_index - sub_matching_begin + 1 < 2) @@ -335,6 +338,11 @@ class MapMatching final : public BasicRoutingInterface