Welcome to mirror list, hosted at ThFree Co, Russian Federation.

graph.cpp « openlr - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6911cb5eff1828eca79a69e9abbca9c87cabc7dd (plain)
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
#include "openlr/graph.hpp"

#include "indexer/index.hpp"

using namespace routing;

namespace openlr
{
namespace
{
using EdgeGetter = void (IRoadGraph::*)(Junction const &, RoadGraphBase::TEdgeVector &) 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(Index const & index, shared_ptr<CarModelFactory> carModelFactory)
  : m_graph(index, 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::AddFakeEdges(Junction const & junction, vector<pair<Edge, Junction>> const & vicinities)
{
  m_graph.AddFakeEdges(junction, vicinities);
}

void Graph::AddIngoingFakeEdge(Edge const & e)
{
  m_graph.AddIngoingFakeEdge(e);
}

void Graph::AddOutgoingFakeEdge(Edge const & e)
{
  m_graph.AddOutgoingFakeEdge(e);
}
}  // namespace openlr