2015-02-26 12:50:18 -05:00
|
|
|
#ifndef MAP_MATCHING_HPP
|
|
|
|
#define MAP_MATCHING_HPP
|
2014-09-23 12:46:14 -04:00
|
|
|
|
2017-01-05 06:18:45 -05:00
|
|
|
#include "engine/datafacade/datafacade_base.hpp"
|
2016-01-02 11:13:44 -05:00
|
|
|
#include "engine/routing_algorithms/routing_base.hpp"
|
2014-09-23 12:46:14 -04:00
|
|
|
|
2016-01-02 11:13:44 -05:00
|
|
|
#include "engine/map_matching/hidden_markov_model.hpp"
|
2016-02-20 22:27:26 -05:00
|
|
|
#include "engine/map_matching/matching_confidence.hpp"
|
2016-05-27 15:05:04 -04:00
|
|
|
#include "engine/map_matching/sub_matching.hpp"
|
2016-02-20 22:27:26 -05:00
|
|
|
|
2016-11-01 17:13:10 -04:00
|
|
|
#include "extractor/profile_properties.hpp"
|
2016-02-20 22:27:26 -05:00
|
|
|
#include "util/coordinate_calculation.hpp"
|
|
|
|
#include "util/for_each_pair.hpp"
|
2014-09-23 12:46:14 -04:00
|
|
|
|
2015-09-18 08:26:32 -04:00
|
|
|
#include <cstddef>
|
2015-02-26 12:50:18 -05:00
|
|
|
|
2014-09-23 12:46:14 -04:00
|
|
|
#include <algorithm>
|
2015-09-18 08:26:32 -04:00
|
|
|
#include <deque>
|
2014-09-23 12:46:14 -04:00
|
|
|
#include <iomanip>
|
2017-01-05 06:18:45 -05:00
|
|
|
#include <memory>
|
2014-09-23 12:46:14 -04:00
|
|
|
#include <numeric>
|
2015-09-18 08:26:32 -04:00
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
2014-09-23 12:46:14 -04:00
|
|
|
|
2015-03-03 06:48:33 -05:00
|
|
|
namespace osrm
|
|
|
|
{
|
2016-01-05 10:51:13 -05:00
|
|
|
namespace engine
|
|
|
|
{
|
|
|
|
namespace routing_algorithms
|
2014-09-23 12:46:14 -04:00
|
|
|
{
|
2015-02-17 06:22:11 -05:00
|
|
|
|
2015-12-09 16:34:22 -05:00
|
|
|
using CandidateList = std::vector<PhantomNodeWithDistance>;
|
2015-02-17 06:22:11 -05:00
|
|
|
using CandidateLists = std::vector<CandidateList>;
|
2016-01-05 10:51:13 -05:00
|
|
|
using HMM = map_matching::HiddenMarkovModel<CandidateLists>;
|
2016-02-20 22:27:26 -05:00
|
|
|
using SubMatchingList = std::vector<map_matching::SubMatching>;
|
2015-03-03 06:48:33 -05:00
|
|
|
|
2015-08-26 17:27:47 -04:00
|
|
|
constexpr static const unsigned MAX_BROKEN_STATES = 10;
|
2016-02-20 22:27:26 -05:00
|
|
|
static const constexpr double MATCHING_BETA = 10;
|
2016-03-07 18:11:35 -05:00
|
|
|
constexpr static const double MAX_DISTANCE_DELTA = 2000.;
|
2014-09-23 12:46:14 -04:00
|
|
|
|
|
|
|
// implements a hidden markov model map matching algorithm
|
2017-01-05 06:18:45 -05:00
|
|
|
class MapMatching final : public BasicRoutingInterface
|
2014-09-23 12:46:14 -04:00
|
|
|
{
|
2017-01-05 06:18:45 -05:00
|
|
|
using super = BasicRoutingInterface;
|
2014-09-23 12:46:14 -04:00
|
|
|
using QueryHeap = SearchEngineData::QueryHeap;
|
|
|
|
SearchEngineData &engine_working_data;
|
2016-02-20 22:27:26 -05:00
|
|
|
map_matching::EmissionLogProbability default_emission_log_probability;
|
|
|
|
map_matching::TransitionLogProbability transition_log_probability;
|
|
|
|
map_matching::MatchingConfidence confidence;
|
2016-11-01 17:13:10 -04:00
|
|
|
extractor::ProfileProperties m_profile_properties;
|
2014-09-23 12:46:14 -04:00
|
|
|
|
2017-01-05 06:18:45 -05:00
|
|
|
unsigned GetMedianSampleTime(const std::vector<unsigned> ×tamps) const;
|
2015-08-26 17:27:47 -04:00
|
|
|
|
2014-09-23 12:46:14 -04:00
|
|
|
public:
|
2016-10-05 06:33:58 -04:00
|
|
|
MapMatching(SearchEngineData &engine_working_data, const double default_gps_precision)
|
2016-10-05 19:05:03 -04:00
|
|
|
: engine_working_data(engine_working_data),
|
2016-02-20 22:27:26 -05:00
|
|
|
default_emission_log_probability(default_gps_precision),
|
|
|
|
transition_log_probability(MATCHING_BETA)
|
2014-09-23 12:46:14 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-02-20 22:27:26 -05:00
|
|
|
SubMatchingList
|
2017-01-05 06:18:45 -05:00
|
|
|
operator()(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
|
2016-10-05 19:05:03 -04:00
|
|
|
const CandidateLists &candidates_list,
|
2016-02-23 15:23:13 -05:00
|
|
|
const std::vector<util::Coordinate> &trace_coordinates,
|
2016-02-20 22:27:26 -05:00
|
|
|
const std::vector<unsigned> &trace_timestamps,
|
2017-01-05 06:18:45 -05:00
|
|
|
const std::vector<boost::optional<double>> &trace_gps_precision) const;
|
2014-09-23 12:46:14 -04:00
|
|
|
};
|
2016-01-05 10:51:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-27 05:17:19 -05:00
|
|
|
//[1] "Hidden Markov Map Matching Through Noise and Sparseness"; P. Newson and J. Krumm; 2009; ACM
|
2015-03-03 05:48:15 -05:00
|
|
|
// GIS
|
2014-09-23 12:46:14 -04:00
|
|
|
|
2015-02-26 12:50:18 -05:00
|
|
|
#endif /* MAP_MATCHING_HPP */
|