Fast map matching  0.1.0
stmatch_algorithm.hpp
1 
9 #ifndef FMM_STMATCH_ALGORITHM_HPP
10 #define FMM_STMATCH_ALGORITHM_HPP
11 
12 #include "network/network.hpp"
13 #include "network/network_graph.hpp"
14 #include "mm/composite_graph.hpp"
15 #include "mm/transition_graph.hpp"
16 #include "mm/mm_type.hpp"
17 #include "python/pyfmm.hpp"
18 
19 #include <string>
20 #include <boost/property_tree/ptree.hpp>
21 #include <boost/property_tree/xml_parser.hpp>
22 
23 #include "cxxopts/cxxopts.hpp"
24 
25 namespace FMM {
26 namespace MM{
27 
31 struct STMATCHConfig {
42  STMATCHConfig(int k_arg = 8, double r_arg = 300, double gps_error_arg = 50,
43  double vmax_arg = 30, double factor_arg = 1.5);
44  int k;
45  double radius;
46  double gps_error;
47  double vmax;
48  double factor;
53  bool validate() const;
57  void print() const;
62  const boost::property_tree::ptree &xml_data);
67  const cxxopts::ParseResult &arg_data);
68 };
69 
73 class STMATCH {
74  public:
78  STMATCH(const NETWORK::Network &network, const NETWORK::NetworkGraph &graph) :
79  network_(network), graph_(graph) {
80  };
88  const std::string &wkt,const STMATCHConfig &config);
96  const STMATCHConfig &config);
97  protected:
105  void update_tg(TransitionGraph *tg,
106  const CompositeGraph &cg,
107  const CORE::Trajectory &traj,
108  const STMATCHConfig &config);
118  void update_layer(int level, TGLayer *la_ptr, TGLayer *lb_ptr,
119  const CompositeGraph &cg,
120  double eu_dist,
121  double delta);
122 
135  std::vector<double> shortest_path_upperbound(
136  int level,
137  const CompositeGraph &cg, NETWORK::NodeIndex source,
138  const std::vector<NETWORK::NodeIndex> &targets, double delta);
139 
148  C_Path build_cpath(const TGOpath &tg_opath, std::vector<int> *indices);
149  private:
150  const NETWORK::Network &network_;
151  const NETWORK::NetworkGraph &graph_;
152 };// STMATCH
153 }
154 } // FMM
155 
156 #endif
FMM::MM::TransitionGraph
Transition graph class in HMM.
Definition: transition_graph.hpp:54
FMM::MM::STMATCHConfig::factor
double factor
factor multiplied to vmax*deltaT to limit the search of shortest path
Definition: stmatch_algorithm.hpp:48
FMM::MM::STMATCHConfig::load_from_arg
static STMATCHConfig load_from_arg(const cxxopts::ParseResult &arg_data)
Load from argument parsed data.
Definition: stmatch_algorithm.cpp:37
FMM::MM::TGOpath
std::vector< const TGNode * > TGOpath
The optimal path of nodes in the transition graph.
Definition: transition_graph.hpp:46
FMM::MM::STMATCHConfig::vmax
double vmax
maximum speed of the vehicle, unit is map_unit/second
Definition: stmatch_algorithm.hpp:47
FMM::MM::STMATCH::STMATCH
STMATCH(const NETWORK::Network &network, const NETWORK::NetworkGraph &graph)
Create a stmatch model from network and graph.
Definition: stmatch_algorithm.hpp:78
FMM::MM::MatchResult
Map matched result representation.
Definition: mm_type.hpp:69
FMM::MM::STMATCHConfig::gps_error
double gps_error
GPS error, unit is map_unit.
Definition: stmatch_algorithm.hpp:46
FMM::MM::STMATCH::shortest_path_upperbound
std::vector< double > shortest_path_upperbound(int level, const CompositeGraph &cg, NETWORK::NodeIndex source, const std::vector< NETWORK::NodeIndex > &targets, double delta)
Return distances from source to all targets and with an upper bound of delta to stop the search.
Definition: stmatch_algorithm.cpp:189
FMM::MM::STMATCHConfig::radius
double radius
search radius for candidates, unit is map_unit
Definition: stmatch_algorithm.hpp:45
FMM::PYTHON::PyMatchResult
POD Match result type used in Python API.
Definition: pyfmm.hpp:39
FMM::MM::C_Path
std::vector< FMM::NETWORK::EdgeID > C_Path
Complete path, ids of a sequence of topologically connected edges.
Definition: mm_type.hpp:47
FMM::MM::STMATCHConfig::print
void print() const
Print configuration data.
Definition: stmatch_algorithm.cpp:21
FMM::MM::STMATCHConfig::load_from_xml
static STMATCHConfig load_from_xml(const boost::property_tree::ptree &xml_data)
Load from xml data.
Definition: stmatch_algorithm.cpp:27
FMM
Fast map matching.
Definition: geom_algorithm.hpp:17
FMM::CORE::Trajectory
Trajectory class
Definition: gps.hpp:26
FMM::NETWORK::Network
Road network class.
Definition: network.hpp:36
FMM::MM::STMATCH
STMATCH algorithm/model
Definition: stmatch_algorithm.hpp:73
FMM::NETWORK::NetworkGraph
Graph class of the network.
Definition: network_graph.hpp:33
FMM::MM::STMATCH::update_tg
void update_tg(TransitionGraph *tg, const CompositeGraph &cg, const CORE::Trajectory &traj, const STMATCHConfig &config)
Update probabilities in a transition graph.
Definition: stmatch_algorithm.cpp:133
FMM::MM::STMATCH::update_layer
void update_layer(int level, TGLayer *la_ptr, TGLayer *lb_ptr, const CompositeGraph &cg, double eu_dist, double delta)
Update probabilities between two layers a and b in the transition graph.
Definition: stmatch_algorithm.cpp:157
FMM::MM::CompositeGraph
Composite Graph as a wrapper of network graph and dummy graph.
Definition: composite_graph.hpp:136
FMM::MM::STMATCHConfig
Configuration of stmatch algorithm.
Definition: stmatch_algorithm.hpp:31
FMM::MM::STMATCH::build_cpath
C_Path build_cpath(const TGOpath &tg_opath, std::vector< int > *indices)
Create a topologically connected path according to each matched candidate.
Definition: stmatch_algorithm.cpp:261
FMM::NETWORK::NodeIndex
unsigned int NodeIndex
Node Index in the network, range from [0,num_vertices-1 ].
Definition: type.hpp:24
FMM::MM::STMATCH::match_wkt
PYTHON::PyMatchResult match_wkt(const std::string &wkt, const STMATCHConfig &config)
Match a wkt linestring to the road network.
Definition: stmatch_algorithm.cpp:56
FMM::MM::STMATCH::match_traj
MatchResult match_traj(const CORE::Trajectory &traj, const STMATCHConfig &config)
Match a trajectory to the road network.
Definition: stmatch_algorithm.cpp:88
FMM::MM::TGLayer
std::vector< TGNode > TGLayer
A layer of nodes in the transition graph.
Definition: transition_graph.hpp:42
FMM::MM::STMATCHConfig::k
int k
number of candidates
Definition: stmatch_algorithm.hpp:44
FMM::MM::STMATCHConfig::validate
bool validate() const
Check the validity of the configuration.
Definition: stmatch_algorithm.cpp:47
FMM::MM::STMATCHConfig::STMATCHConfig
STMATCHConfig(int k_arg=8, double r_arg=300, double gps_error_arg=50, double vmax_arg=30, double factor_arg=1.5)
Constructor of stmatch algorithm configuration.
Definition: stmatch_algorithm.cpp:14