From d43716612b5f7730bbc3767367c2b797957b0e2a Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Tue, 3 Mar 2015 18:17:12 +0100 Subject: [PATCH] several copyedits to brush up code - remove unneeded includes - replace size() <==> 0 comparisions with calls to empty() - use fp instead of integer literals - use range-based for loops with integer ranges - add a couple of consts --- routing_algorithms/map_matching.hpp | 36 +++++++++++++---------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/routing_algorithms/map_matching.hpp b/routing_algorithms/map_matching.hpp index d2e3c395b..4246539ef 100644 --- a/routing_algorithms/map_matching.hpp +++ b/routing_algorithms/map_matching.hpp @@ -33,15 +33,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../data_structures/coordinate_calculation.hpp" #include "../data_structures/hidden_markov_model.hpp" #include "../util/matching_debug_info.hpp" -#include "../util/simple_logger.hpp" -#include "../util/json_util.hpp" #include "../util/json_logger.hpp" -#include #include -#include - #include #include #include @@ -93,13 +88,13 @@ class MapMatching final : public BasicRoutingInterface 0); + BOOST_ASSERT(!candidates_list.empty()); // TODO replace default values with table lookup based on sampling frequency EmissionLogProbability emission_log_probability( - gps_precision > 0 ? gps_precision : osrm::matching::default_sigma_z); + gps_precision > 0. ? gps_precision : osrm::matching::default_sigma_z); TransitionLogProbability transition_log_probability( - matching_beta > 0 ? matching_beta : osrm::matching::default_beta); + matching_beta > 0. ? matching_beta : osrm::matching::default_beta); osrm::matching::HMM model(candidates_list, emission_log_probability); @@ -120,10 +115,10 @@ class MapMatching final : public BasicRoutingInterface 0) + if (!trace_timestamps.empty()) { trace_split = trace_split || @@ -162,7 +157,8 @@ class MapMatching final : public BasicRoutingInterface(0u, prev_viterbi.size())) { if (prev_pruned[s]) + { continue; + } - for (auto s_prime = 0u; s_prime < current_viterbi.size(); ++s_prime) + for (const auto s_prime : osrm::irange(0u, current_viterbi.size())) { // how likely is candidate s_prime at time t to be emitted? const double emission_pr = @@ -247,7 +245,6 @@ class MapMatching final : public BasicRoutingInterface 0); - // remove both ends of the breakage prev_unbroken_timestamps.pop_back(); } @@ -259,7 +256,7 @@ class MapMatching final : public BasicRoutingInterface 0) + if (!prev_unbroken_timestamps.empty()) { split_points.push_back(prev_unbroken_timestamps.back() + 1); } @@ -286,8 +283,9 @@ class MapMatching final : public BasicRoutingInterface(0u, reconstructed_indices.size())) { auto timestamp_index = reconstructed_indices[i].first; auto location_index = reconstructed_indices[i].second; @@ -328,10 +326,8 @@ class MapMatching final : public BasicRoutingInterface