diff --git a/data_structures/hidden_markov_model.hpp b/data_structures/hidden_markov_model.hpp index bae2ba55a..403f76608 100644 --- a/data_structures/hidden_markov_model.hpp +++ b/data_structures/hidden_markov_model.hpp @@ -41,7 +41,6 @@ namespace osrm { namespace matching { -// FIXME this value should be a table based on samples/meter (or samples/min) static const double log_2_pi = std::log(2. * M_PI); static const double IMPOSSIBLE_LOG_PROB = -std::numeric_limits::infinity(); static const double MINIMAL_LOG_PROB = std::numeric_limits::lowest(); diff --git a/routing_algorithms/map_matching.hpp b/routing_algorithms/map_matching.hpp index 89c4e357c..80fe49cce 100644 --- a/routing_algorithms/map_matching.hpp +++ b/routing_algorithms/map_matching.hpp @@ -88,7 +88,7 @@ class MapMatching final : public BasicRoutingInterface::max(); - std::vector split_points; - std::vector prev_unbroken_timestamps; + std::size_t breakage_begin = osrm::matching::INVALID_STATE; + std::vector split_points; + std::vector prev_unbroken_timestamps; prev_unbroken_timestamps.reserve(candidates_list.size()); prev_unbroken_timestamps.push_back(initial_timestamp); for (auto t = initial_timestamp + 1; t < candidates_list.size(); ++t) @@ -133,22 +133,23 @@ class MapMatching final : public BasicRoutingInterface::max()) + std::size_t split_index = t; + if (breakage_begin != osrm::matching::INVALID_STATE) { split_index = breakage_begin; - breakage_begin = std::numeric_limits::max(); + breakage_begin = osrm::matching::INVALID_STATE; } split_points.push_back(split_index); // note: this preserves everything before split_index model.clear(split_index); - unsigned new_start = model.initialize(split_index); + std::size_t new_start = model.initialize(split_index); // no new start was found -> stop viterbi calculation if (new_start == osrm::matching::INVALID_STATE) { break; } + prev_unbroken_timestamps.clear(); prev_unbroken_timestamps.push_back(new_start); // Important: We potentially go back here! @@ -158,7 +159,7 @@ class MapMatching final : public BasicRoutingInterface= sub_matching_begin && model.breakage[parent_timestamp_index]) { @@ -287,10 +288,10 @@ class MapMatching final : public BasicRoutingInterface> reconstructed_indices; + std::deque> reconstructed_indices; while (parent_timestamp_index > sub_matching_begin) { if (model.breakage[parent_timestamp_index])