/
githubmirror
/
omim
Обзор
Документация
Войти
/
githubmirror
/
omim
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
android-951
openlr/graph.cpp
88 строк
2 KB
Mikhail Gorbushin
[geometry] Get rid of MercatorBounds, refactor to namespace mercator
01 ноя 2019, 11:09
01 ноя 2019, 11:09
6f5d401
Код
Авторство
О чём код?
#include "openlr/graph.hpp" #include "geometry/mercator.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( mercator::RectByCenterXYAndSizeInMeters(point, FeaturesRoadGraph::kClosestEdgesRadiusM), 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