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

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Magidovich <mgsergio@mapswithme.com>2017-12-18 14:41:33 +0300
committerYuri Gorshenin <mipt.vi002@gmail.com>2018-02-07 13:48:18 +0300
commit774e6930d8377a903a03376a72f90d1cb420d5ce (patch)
treedb029f78c01e508c79bc67bb182606fdf334b5c9 /openlr/graph.cpp
parent2be0781941a5b9be7e0209bcbe72a2e623cad546 (diff)
[OpenLR] Assemble all things together. Cache edges within one run.
Diffstat (limited to 'openlr/graph.cpp')
-rw-r--r--openlr/graph.cpp44
1 files changed, 35 insertions, 9 deletions
diff --git a/openlr/graph.cpp b/openlr/graph.cpp
index 2114d3de65..6911cb5eff 100644
--- a/openlr/graph.cpp
+++ b/openlr/graph.cpp
@@ -6,32 +6,58 @@ 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) const
+void Graph::GetOutgoingEdges(Junction const & junction, EdgeVector & edges)
{
- m_graph.GetOutgoingEdges(junction, edges);
+ GetRegularOutgoingEdges(junction, edges);
+ m_graph.GetFakeOutgoingEdges(junction, edges);
}
-void Graph::GetIngoingEdges(Junction const & junction, EdgeVector & edges) const
+void Graph::GetIngoingEdges(Junction const & junction, EdgeVector & edges)
{
- m_graph.GetIngoingEdges(junction, edges);
+ GetRegularIngoingEdges(junction, edges);
+ m_graph.GetFakeIngoingEdges(junction, edges);
}
-void Graph::GetRegularOutgoingEdges(Junction const & junction, EdgeVector & edges) const
+void Graph::GetRegularOutgoingEdges(Junction const & junction, EdgeVector & edges)
{
- m_graph.GetRegularOutgoingEdges(junction, edges);
+ GetRegularEdges(junction, m_graph, &IRoadGraph::GetRegularOutgoingEdges, m_outgoingCache, edges);
}
-void Graph::GetRegularIngoingEdges(Junction const & junction, EdgeVector & edges) const
+void Graph::GetRegularIngoingEdges(Junction const & junction, EdgeVector & edges)
{
- m_graph.GetRegularIngoingEdges(junction, edges);
+ GetRegularEdges(junction, m_graph, &IRoadGraph::GetRegularIngoingEdges, m_ingoingCache, edges);
}
-void Graph::FindClosestEdges(m2::PointD const & point, uint32_t count,
+void Graph::FindClosestEdges(m2::PointD const & point, uint32_t const count,
vector<pair<Edge, Junction>> & vicinities) const
{
m_graph.FindClosestEdges(point, count, vicinities);