Remove obsolete debug information
This commit is contained in:
		
							parent
							
								
									3d3fea768c
								
							
						
					
					
						commit
						056a7422e0
					
				@ -10,7 +10,6 @@
 | 
				
			|||||||
#include "util/coordinate_calculation.hpp"
 | 
					#include "util/coordinate_calculation.hpp"
 | 
				
			||||||
#include "util/json_logger.hpp"
 | 
					#include "util/json_logger.hpp"
 | 
				
			||||||
#include "util/for_each_pair.hpp"
 | 
					#include "util/for_each_pair.hpp"
 | 
				
			||||||
#include "util/matching_debug_info.hpp"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <cstddef>
 | 
					#include <cstddef>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -162,9 +161,6 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
 | 
				
			|||||||
            return sub_matchings;
 | 
					            return sub_matchings;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        util::MatchingDebugInfo matching_debug(util::json::Logger::get());
 | 
					 | 
				
			||||||
        matching_debug.initialize(candidates_list);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        engine_working_data.InitializeOrClearFirstThreadLocalStorage(
 | 
					        engine_working_data.InitializeOrClearFirstThreadLocalStorage(
 | 
				
			||||||
            super::facade->GetNumberOfNodes());
 | 
					            super::facade->GetNumberOfNodes());
 | 
				
			||||||
        engine_working_data.InitializeOrClearSecondThreadLocalStorage(
 | 
					        engine_working_data.InitializeOrClearSecondThreadLocalStorage(
 | 
				
			||||||
@ -297,10 +293,6 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
 | 
				
			|||||||
                    const double transition_pr = transition_log_probability(d_t);
 | 
					                    const double transition_pr = transition_log_probability(d_t);
 | 
				
			||||||
                    new_value += transition_pr;
 | 
					                    new_value += transition_pr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    matching_debug.add_transition_info(prev_unbroken_timestamp, t, s, s_prime,
 | 
					 | 
				
			||||||
                                                       prev_viterbi[s], emission_pr, transition_pr,
 | 
					 | 
				
			||||||
                                                       network_distance, haversine_distance);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    if (new_value > current_viterbi[s_prime])
 | 
					                    if (new_value > current_viterbi[s_prime])
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        current_viterbi[s_prime] = new_value;
 | 
					                        current_viterbi[s_prime] = new_value;
 | 
				
			||||||
@ -330,8 +322,6 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        matching_debug.set_viterbi(model.viterbi, model.pruned);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (!prev_unbroken_timestamps.empty())
 | 
					        if (!prev_unbroken_timestamps.empty())
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            split_points.push_back(prev_unbroken_timestamps.back() + 1);
 | 
					            split_points.push_back(prev_unbroken_timestamps.back() + 1);
 | 
				
			||||||
@ -406,8 +396,6 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
 | 
				
			|||||||
                matching.nodes.push_back(
 | 
					                matching.nodes.push_back(
 | 
				
			||||||
                    candidates_list[timestamp_index][location_index].phantom_node);
 | 
					                    candidates_list[timestamp_index][location_index].phantom_node);
 | 
				
			||||||
                matching_distance += model.path_distances[timestamp_index][location_index];
 | 
					                matching_distance += model.path_distances[timestamp_index][location_index];
 | 
				
			||||||
 | 
					 | 
				
			||||||
                matching_debug.add_chosen(timestamp_index, location_index);
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            util::for_each_pair(
 | 
					            util::for_each_pair(
 | 
				
			||||||
                reconstructed_indices, [&trace_distance, &trace_coordinates](
 | 
					                reconstructed_indices, [&trace_distance, &trace_coordinates](
 | 
				
			||||||
@ -423,7 +411,6 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
 | 
				
			|||||||
            sub_matchings.push_back(matching);
 | 
					            sub_matchings.push_back(matching);
 | 
				
			||||||
            sub_matching_begin = sub_matching_end;
 | 
					            sub_matching_begin = sub_matching_end;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        matching_debug.add_breakage(model.breakage);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return sub_matchings;
 | 
					        return sub_matchings;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -1,142 +0,0 @@
 | 
				
			|||||||
#ifndef MATCHING_DEBUG_INFO_HPP
 | 
					 | 
				
			||||||
#define MATCHING_DEBUG_INFO_HPP
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "util/json_logger.hpp"
 | 
					 | 
				
			||||||
#include "util/json_util.hpp"
 | 
					 | 
				
			||||||
#include "engine/map_matching/hidden_markov_model.hpp"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "osrm/coordinate.hpp"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace osrm
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
namespace util
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Provides the debug interface for introspection tools
 | 
					 | 
				
			||||||
struct MatchingDebugInfo
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    MatchingDebugInfo(const json::Logger *logger) : logger(logger)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        if (logger)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            object = &logger->map->at("matching");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    template <class CandidateLists> void initialize(const CandidateLists &candidates_list)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        // json logger not enabled
 | 
					 | 
				
			||||||
        if (!logger)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        json::Array states;
 | 
					 | 
				
			||||||
        for (auto &elem : candidates_list)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            json::Array timestamps;
 | 
					 | 
				
			||||||
            for (auto &elem_s : elem)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                json::Object state;
 | 
					 | 
				
			||||||
                state.values["transitions"] = json::Array();
 | 
					 | 
				
			||||||
                state.values["coordinate"] = json::make_array(
 | 
					 | 
				
			||||||
                    static_cast<double>(toFloating(elem_s.phantom_node.location.lat)),
 | 
					 | 
				
			||||||
                    static_cast<double>(toFloating(elem_s.phantom_node.location.lon)));
 | 
					 | 
				
			||||||
                state.values["viterbi"] =
 | 
					 | 
				
			||||||
                    json::clamp_float(engine::map_matching::IMPOSSIBLE_LOG_PROB);
 | 
					 | 
				
			||||||
                state.values["pruned"] = 0u;
 | 
					 | 
				
			||||||
                timestamps.values.push_back(state);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            states.values.push_back(timestamps);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        json::get(*object, "states") = states;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    void add_transition_info(const unsigned prev_t,
 | 
					 | 
				
			||||||
                             const unsigned current_t,
 | 
					 | 
				
			||||||
                             const unsigned prev_state,
 | 
					 | 
				
			||||||
                             const unsigned current_state,
 | 
					 | 
				
			||||||
                             const double prev_viterbi,
 | 
					 | 
				
			||||||
                             const double emission_pr,
 | 
					 | 
				
			||||||
                             const double transition_pr,
 | 
					 | 
				
			||||||
                             const double network_distance,
 | 
					 | 
				
			||||||
                             const double haversine_distance)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        // json logger not enabled
 | 
					 | 
				
			||||||
        if (!logger)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        json::Object transistion;
 | 
					 | 
				
			||||||
        transistion.values["to"] = json::make_array(current_t, current_state);
 | 
					 | 
				
			||||||
        transistion.values["properties"] = json::make_array(
 | 
					 | 
				
			||||||
            json::clamp_float(prev_viterbi), json::clamp_float(emission_pr),
 | 
					 | 
				
			||||||
            json::clamp_float(transition_pr), network_distance, haversine_distance);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        json::get(*object, "states", prev_t, prev_state, "transitions")
 | 
					 | 
				
			||||||
            .get<mapbox::util::recursive_wrapper<json::Array>>()
 | 
					 | 
				
			||||||
            .get()
 | 
					 | 
				
			||||||
            .values.push_back(transistion);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    void set_viterbi(const std::vector<std::vector<double>> &viterbi,
 | 
					 | 
				
			||||||
                     const std::vector<std::vector<bool>> &pruned)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        // json logger not enabled
 | 
					 | 
				
			||||||
        if (!logger)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        for (auto t = 0u; t < viterbi.size(); t++)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            for (auto s_prime = 0u; s_prime < viterbi[t].size(); ++s_prime)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                json::get(*object, "states", t, s_prime, "viterbi") =
 | 
					 | 
				
			||||||
                    json::clamp_float(viterbi[t][s_prime]);
 | 
					 | 
				
			||||||
                json::get(*object, "states", t, s_prime, "pruned") =
 | 
					 | 
				
			||||||
                    static_cast<unsigned>(pruned[t][s_prime]);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    void add_chosen(const unsigned t, const unsigned s)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        // json logger not enabled
 | 
					 | 
				
			||||||
        if (!logger)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        json::get(*object, "states", t, s, "chosen") = true;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    void add_breakage(const std::vector<bool> &breakage)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        // json logger not enabled
 | 
					 | 
				
			||||||
        if (!logger)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // convert std::vector<bool> to osrm::json::Array
 | 
					 | 
				
			||||||
        json::Array a;
 | 
					 | 
				
			||||||
        for (const bool v : breakage)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (v)
 | 
					 | 
				
			||||||
                a.values.emplace_back(json::True());
 | 
					 | 
				
			||||||
            else
 | 
					 | 
				
			||||||
                a.values.emplace_back(json::False());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        json::get(*object, "breakage") = std::move(a);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    const json::Logger *logger;
 | 
					 | 
				
			||||||
    json::Value *object;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif // MATCHING_DEBUG_INFO_HPP
 | 
					 | 
				
			||||||
@ -159,10 +159,6 @@ Status MatchPlugin::HandleRequest(const api::MatchParameters ¶meters,
 | 
				
			|||||||
                     json_result);
 | 
					                     json_result);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // setup logging if enabled
 | 
					 | 
				
			||||||
    if (util::json::Logger::get())
 | 
					 | 
				
			||||||
        util::json::Logger::get()->initialize("matching");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // call the actual map matching
 | 
					    // call the actual map matching
 | 
				
			||||||
    SubMatchingList sub_matchings = map_matching(candidates_lists, parameters.coordinates,
 | 
					    SubMatchingList sub_matchings = map_matching(candidates_lists, parameters.coordinates,
 | 
				
			||||||
                                                 parameters.timestamps, parameters.radiuses);
 | 
					                                                 parameters.timestamps, parameters.radiuses);
 | 
				
			||||||
@ -195,9 +191,6 @@ Status MatchPlugin::HandleRequest(const api::MatchParameters ¶meters,
 | 
				
			|||||||
    api::MatchAPI match_api{BasePlugin::facade, parameters};
 | 
					    api::MatchAPI match_api{BasePlugin::facade, parameters};
 | 
				
			||||||
    match_api.MakeResponse(sub_matchings, sub_routes, json_result);
 | 
					    match_api.MakeResponse(sub_matchings, sub_routes, json_result);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (util::json::Logger::get())
 | 
					 | 
				
			||||||
        util::json::Logger::get()->render("matching", json_result);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return Status::Ok;
 | 
					    return Status::Ok;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user