10 #ifndef FMM_NETWORK_HPP
11 #define FMM_NETWORK_HPP
13 #include "network/type.hpp"
14 #include "core/gps.hpp"
15 #include "mm/mm_type.hpp"
16 #include <ogrsf_frmts.h>
21 #include <unordered_set>
24 #include <boost/geometry/geometries/box.hpp>
25 #include <boost/geometry/index/rtree.hpp>
26 #include <boost/function_output_iterator.hpp>
41 typedef boost::geometry::model::box<FMM::CORE::Point>
boost_box;
45 typedef std::pair<boost_box, Edge *>
Item;
49 typedef boost::geometry::index::rtree<
50 Item, boost::geometry::index::quadratic<16> >
Rtree;
60 Network(
const std::string &filename,
61 const std::string &id_name =
"id",
62 const std::string &source_name =
"source",
63 const std::string &target_name =
"target");
78 const std::vector<Edge> &
get_edges()
const;
136 double radius)
const;
175 const std::vector<EdgeIndex> &path)
const;
198 void build_rtree_index();
201 std::vector<Edge> edges;
203 unsigned int num_vertices;
206 std::vector<FMM::CORE::Point> vertex_points;
int get_node_count() const
Get number of nodes in the network.
std::vector< Point_Candidates > Traj_Candidates
trajectory candidates
const std::vector< Edge > & get_edges() const
Get edges in the network.
FMM::CORE::LineString complete_path_to_geometry(const FMM::CORE::LineString &traj, const MM::C_Path &complete_path) const
Extract the geometry of a complete path, whose two end segment will be clipped according to the input...
const FMM::CORE::Point & get_vertex_point(NodeIndex u) const
Get node geometry.
std::vector< NodeID > NodeIDVec
Vector of node id.
boost::geometry::model::box< FMM::CORE::Point > boost_box
Box of a edge.
const std::vector< FMM::CORE::Point > & get_vertex_points() const
Get all node geometry.
NodeID get_node_id(NodeIndex index) const
Get node ID from index.
std::vector< FMM::NETWORK::EdgeID > C_Path
Complete path, ids of a sequence of topologically connected edges.
std::pair< boost_box, Edge * > Item
Item stored in a node of Rtree.
const FMM::CORE::LineString & get_edge_geom(EdgeID edge_id) const
Get edge geometry.
int get_edge_count() const
Get number of edges in the network.
FMM::MM::Traj_Candidates search_tr_cs_knn(FMM::CORE::Trajectory &trajectory, std::size_t k, double radius) const
Search for k nearest neighboring (KNN) candidates of a trajectory within a search radius.
NodeIndex get_node_index(NodeID id) const
Get node index from id.
EdgeID get_edge_id(EdgeIndex index) const
Get edge ID from index.
int EdgeID
Edge ID in the network, can be discontinuous int.
Candidate edge matched to a GPS point
FMM::CORE::Point get_node_geom_from_idx(NodeIndex index) const
Get node geometry from index.
Linestring geometry class.
EdgeIndex get_edge_index(EdgeID id) const
Get edge index from ID.
static bool candidate_compare(const MM::Candidate &a, const MM::Candidate &b)
Compare two candidate according to their GPS error.
int NodeID
Node ID in the network, can be discontinuous int.
Network(const std::string &filename, const std::string &id_name="id", const std::string &source_name="source", const std::string &target_name="target")
Constructor of Network.
unsigned int NodeIndex
Node Index in the network, range from [0,num_vertices-1 ].
std::unordered_map< EdgeID, EdgeIndex > EdgeIndexMap
Map of edge index.
unsigned int EdgeIndex
Edge Index in the network, range from [0,num_edges-1 ].
boost::geometry::model::point< double, 2, boost::geometry::cs::cartesian > Point
Point class.
std::unordered_map< NodeID, NodeIndex > NodeIndexMap
Map of node index.
FMM::CORE::LineString route2geometry(const std::vector< EdgeID > &path) const
Extract the geometry of a route in the network.
boost::geometry::index::rtree< Item, boost::geometry::index::quadratic< 16 > > Rtree
Rtree of road edges.