1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#include "openlr/graph.hpp"
#include <map>
#include <memory>
#include <utility>
#include <vector>
using namespace routing;
using namespace std;
namespace openlr
{
namespace
{
using EdgeGetter = void (IRoadGraph::*)(Junction const &, RoadGraphBase::EdgeVector &) const;
void GetRegularEdges(Junction const & junction, IRoadGraph const & graph,
EdgeGetter const edgeGetter,
map<openlr::Graph::Junction, Graph::EdgeVector> & cache,
Graph::EdgeVector & edges)
{
auto const it = cache.find(junction);
if (it == end(cache))
{
auto & es = cache[junction];
(graph.*edgeGetter)(junction, es);
edges.insert(end(edges), begin(es), end(es));
}
else
{
auto const & es = it->second;
edges.insert(end(edges), begin(es), end(es));
}
}
} // namespace
Graph::Graph(DataSource const & dataSource, shared_ptr<CarModelFactory> carModelFactory)
: m_graph(dataSource, IRoadGraph::Mode::ObeyOnewayTag, carModelFactory)
{
}
void Graph::GetOutgoingEdges(Junction const & junction, EdgeVector & edges)
{
GetRegularOutgoingEdges(junction, edges);
m_graph.GetFakeOutgoingEdges(junction, edges);
}
void Graph::GetIngoingEdges(Junction const & junction, EdgeVector & edges)
{
GetRegularIngoingEdges(junction, edges);
m_graph.GetFakeIngoingEdges(junction, edges);
}
void Graph::GetRegularOutgoingEdges(Junction const & junction, EdgeVector & edges)
{
GetRegularEdges(junction, m_graph, &IRoadGraph::GetRegularOutgoingEdges, m_outgoingCache, edges);
}
void Graph::GetRegularIngoingEdges(Junction const & junction, EdgeVector & edges)
{
GetRegularEdges(junction, m_graph, &IRoadGraph::GetRegularIngoingEdges, m_ingoingCache, edges);
}
void Graph::FindClosestEdges(m2::PointD const & point, uint32_t const count,
vector<pair<Edge, Junction>> & vicinities) const
{
m_graph.FindClosestEdges(point, count, vicinities);
}
void Graph::AddIngoingFakeEdge(Edge const & e)
{
m_graph.AddIngoingFakeEdge(e);
}
void Graph::AddOutgoingFakeEdge(Edge const & e)
{
m_graph.AddOutgoingFakeEdge(e);
}
void Graph::GetFeatureTypes(FeatureID const & featureId, feature::TypesHolder & types) const
{
m_graph.GetFeatureTypes(featureId, types);
}
} // namespace openlr
|