diff options
author | Olga Khlopkova <o.khlopkova@corp.mail.ru> | 2019-11-28 12:33:44 +0300 |
---|---|---|
committer | Vladimir Byko-Ianko <bykoianko@gmail.com> | 2019-11-29 11:55:22 +0300 |
commit | dcbd344ff0f699c1106692b1244407b8e1944caa (patch) | |
tree | 0e566596cb5b76f368a8903f03b28b90852503ed /openlr | |
parent | a37a1010f003f49dd72d672a698f22226e6448a4 (diff) |
[geometry] Junction and TAltitude
Diffstat (limited to 'openlr')
-rw-r--r-- | openlr/candidate_paths_getter.cpp | 11 | ||||
-rw-r--r-- | openlr/candidate_paths_getter.hpp | 2 | ||||
-rw-r--r-- | openlr/candidate_points_getter.cpp | 4 | ||||
-rw-r--r-- | openlr/decoded_path.cpp | 4 | ||||
-rw-r--r-- | openlr/graph.cpp | 6 | ||||
-rw-r--r-- | openlr/graph.hpp | 6 | ||||
-rw-r--r-- | openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp | 5 | ||||
-rw-r--r-- | openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp | 8 | ||||
-rw-r--r-- | openlr/openlr_tests/decoded_path_test.cpp | 7 | ||||
-rw-r--r-- | openlr/router.cpp | 32 | ||||
-rw-r--r-- | openlr/router.hpp | 29 | ||||
-rw-r--r-- | openlr/score_candidate_paths_getter.cpp | 3 | ||||
-rw-r--r-- | openlr/score_candidate_paths_getter.hpp | 2 | ||||
-rw-r--r-- | openlr/score_candidate_points_getter.cpp | 11 |
14 files changed, 72 insertions, 58 deletions
diff --git a/openlr/candidate_paths_getter.cpp b/openlr/candidate_paths_getter.cpp index 024584c97e..8ec4f4bfbf 100644 --- a/openlr/candidate_paths_getter.cpp +++ b/openlr/candidate_paths_getter.cpp @@ -10,6 +10,7 @@ #include "platform/location.hpp" #include "geometry/angles.hpp" +#include "geometry/point_with_altitude.hpp" #include <algorithm> #include <iterator> @@ -46,11 +47,11 @@ Graph::Edge CandidatePathsGetter::Link::GetStartEdge() const return start->m_edge; } -bool CandidatePathsGetter::Link::IsJunctionInPath(routing::Junction const & j) const +bool CandidatePathsGetter::Link::IsPointOnPath(geometry::PointWithAltitude const & point) const { for (auto * l = this; l; l = l->m_parent.get()) { - if (l->m_edge.GetEndJunction() == j) + if (l->m_edge.GetEndJunction() == point) { LOG(LDEBUG, ("A loop detected, skipping...")); return true; @@ -104,9 +105,9 @@ void CandidatePathsGetter::GetStartLines(vector<m2::PointD> const & points, bool for (auto const & pc : points) { if (!isLastPoint) - m_graph.GetOutgoingEdges(Junction(pc, 0 /* altitude */), edges); + m_graph.GetOutgoingEdges(geometry::PointWithAltitude(pc, 0 /* altitude */), edges); else - m_graph.GetIngoingEdges(Junction(pc, 0 /* altitude */), edges); + m_graph.GetIngoingEdges(geometry::PointWithAltitude(pc, 0 /* altitude */), edges); } // Same edges may start on different points if those points are close enough. @@ -165,7 +166,7 @@ void CandidatePathsGetter::GetAllSuitablePaths(Graph::EdgeVector const & startLi // TODO(mgsergio): Should we check form of way as well? - if (u->IsJunctionInPath(e.GetEndJunction())) + if (u->IsPointOnPath(e.GetEndJunction())) continue; auto const p = make_shared<Link>(u, e, u->m_distanceM + currentEdgeLen); diff --git a/openlr/candidate_paths_getter.hpp b/openlr/candidate_paths_getter.hpp index 164e5a1632..217cedb14e 100644 --- a/openlr/candidate_paths_getter.hpp +++ b/openlr/candidate_paths_getter.hpp @@ -47,7 +47,7 @@ private: { } - bool IsJunctionInPath(routing::Junction const & j) const; + bool IsPointOnPath(geometry::PointWithAltitude const & point) const; Graph::Edge GetStartEdge() const; diff --git a/openlr/candidate_points_getter.cpp b/openlr/candidate_points_getter.cpp index 22e5920695..355cb927c8 100644 --- a/openlr/candidate_points_getter.cpp +++ b/openlr/candidate_points_getter.cpp @@ -6,6 +6,8 @@ #include "storage/country_info_getter.hpp" +#include "geometry/point_with_altitude.hpp" + #include "base/stl_helpers.hpp" #include <algorithm> @@ -56,7 +58,7 @@ void CandidatePointsGetter::EnrichWithProjectionPoints(m2::PointD const & p, { m_graph.ResetFakes(); - std::vector<std::pair<Graph::Edge, Junction>> vicinities; + std::vector<std::pair<Graph::Edge, geometry::PointWithAltitude>> vicinities; m_graph.FindClosestEdges(p, static_cast<uint32_t>(m_maxProjectionCandidates), vicinities); for (auto const & v : vicinities) { diff --git a/openlr/decoded_path.cpp b/openlr/decoded_path.cpp index c6c19c3737..281542b40e 100644 --- a/openlr/decoded_path.cpp +++ b/openlr/decoded_path.cpp @@ -137,8 +137,8 @@ void PathFromXML(pugi::xml_node const & node, DataSource const & dataSource, Pat p.push_back(Edge::MakeReal( fid, isForward, segmentId, - routing::Junction(mercator::FromLatLon(start), feature::kDefaultAltitudeMeters), - routing::Junction(mercator::FromLatLon(end), feature::kDefaultAltitudeMeters))); + geometry::PointWithAltitude(mercator::FromLatLon(start), geometry::kDefaultAltitudeMeters), + geometry::PointWithAltitude(mercator::FromLatLon(end), geometry::kDefaultAltitudeMeters))); } } diff --git a/openlr/graph.cpp b/openlr/graph.cpp index 0610094953..5d408a43d1 100644 --- a/openlr/graph.cpp +++ b/openlr/graph.cpp @@ -1,6 +1,7 @@ #include "openlr/graph.hpp" #include "geometry/mercator.hpp" +#include "geometry/point_with_altitude.hpp" #include <map> #include <memory> @@ -14,9 +15,10 @@ namespace openlr { namespace { -using EdgeGetter = void (IRoadGraph::*)(Junction const &, RoadGraphBase::EdgeVector &) const; +using EdgeGetter = void (IRoadGraph::*)(geometry::PointWithAltitude const &, + RoadGraphBase::EdgeVector &) const; -void GetRegularEdges(Junction const & junction, IRoadGraph const & graph, +void GetRegularEdges(geometry::PointWithAltitude const & junction, IRoadGraph const & graph, EdgeGetter const edgeGetter, map<openlr::Graph::Junction, Graph::EdgeVector> & cache, Graph::EdgeVector & edges) diff --git a/openlr/graph.hpp b/openlr/graph.hpp index 1c6cf8f7c9..95cf615081 100644 --- a/openlr/graph.hpp +++ b/openlr/graph.hpp @@ -26,14 +26,14 @@ class Graph public: using Edge = routing::Edge; using EdgeVector = routing::FeaturesRoadGraph::EdgeVector; - using Junction = routing::Junction; + using Junction = geometry::PointWithAltitude; Graph(DataSource const & dataSource, std::shared_ptr<routing::CarModelFactory> carModelFactory); // Appends edges such as that edge.GetStartJunction() == junction to the |edges|. - void GetOutgoingEdges(routing::Junction const & junction, EdgeVector & edges); + void GetOutgoingEdges(geometry::PointWithAltitude const & junction, EdgeVector & edges); // Appends edges such as that edge.GetEndJunction() == junction to the |edges|. - void GetIngoingEdges(routing::Junction const & junction, EdgeVector & edges); + void GetIngoingEdges(geometry::PointWithAltitude const & junction, EdgeVector & edges); // Appends edges such as that edge.GetStartJunction() == junction and edge.IsFake() == false // to the |edges|. diff --git a/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp b/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp index 7d88aad8fc..de92b59942 100644 --- a/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp +++ b/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp @@ -202,9 +202,8 @@ public: std::vector<m2::PointD> GetReachablePoints(m2::PointD const & p) const override { routing::FeaturesRoadGraph::EdgeVector edges; - m_roadGraph.GetOutgoingEdges( - routing::Junction(p, feature::kDefaultAltitudeMeters), - edges); + m_roadGraph.GetOutgoingEdges(geometry::PointWithAltitude(p, geometry::kDefaultAltitudeMeters), + edges); std::vector<m2::PointD> points; for (auto const & e : edges) diff --git a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp index 0007e5718c..75e313de85 100644 --- a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp +++ b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp @@ -394,10 +394,10 @@ void TrafficMode::CommitPath() std::tie(prevFid, prevSegId) = prevPoint.GetPoint(); std::tie(fid, segId) = point.GetPoint(); - path.push_back(Edge::MakeReal(fid, prevSegId < segId /* forward */, - base::checked_cast<uint32_t>(prevSegId), - routing::Junction(prevPoint.GetCoordinate(), 0 /* altitude */), - routing::Junction(point.GetCoordinate(), 0 /* altitude */))); + path.push_back(Edge::MakeReal( + fid, prevSegId < segId /* forward */, base::checked_cast<uint32_t>(prevSegId), + geometry::PointWithAltitude(prevPoint.GetCoordinate(), 0 /* altitude */), + geometry::PointWithAltitude(point.GetCoordinate(), 0 /* altitude */))); } m_currentSegment->SetGoldenPath(path); diff --git a/openlr/openlr_tests/decoded_path_test.cpp b/openlr/openlr_tests/decoded_path_test.cpp index 11c3fd33c2..a9035e3edd 100644 --- a/openlr/openlr_tests/decoded_path_test.cpp +++ b/openlr/openlr_tests/decoded_path_test.cpp @@ -46,9 +46,9 @@ double RoughUpToFive(double d) m2::PointD RoughPoint(m2::PointD const & p) { return {RoughUpToFive(p.x), RoughUpToFive(p.y)}; } -routing::Junction RoughJunction(routing::Junction const & j) +geometry::PointWithAltitude RoughJunction(geometry::PointWithAltitude const & j) { - return routing::Junction(RoughPoint(j.GetPoint()), j.GetAltitude()); + return geometry::PointWithAltitude(RoughPoint(j.GetPoint()), j.GetAltitude()); } routing::Edge RoughEdgeJunctions(routing::Edge const & e) @@ -106,7 +106,8 @@ openlr::Path MakePath(FeatureType const & road, bool const forward) path.push_back(routing::Edge::MakeReal( road.GetID(), forward, base::checked_cast<uint32_t>(current - static_cast<size_t>(!forward)) /* segId */, - routing::Junction(from, 0 /* altitude */), routing::Junction(to, 0 /* altitude */))); + geometry::PointWithAltitude(from, 0 /* altitude */), + geometry::PointWithAltitude(to, 0 /* altitude */))); } RoughJunctionsInPath(path); diff --git a/openlr/router.cpp b/openlr/router.cpp index 4043bd03d7..342d18d052 100644 --- a/openlr/router.cpp +++ b/openlr/router.cpp @@ -83,8 +83,9 @@ bool Router::Vertex::Score::operator==(Score const & rhs) const } // Router::Vertex ---------------------------------------------------------------------------------- -Router::Vertex::Vertex(routing::Junction const & junction, routing::Junction const & stageStart, - double stageStartDistance, size_t stage, bool bearingChecked) +Router::Vertex::Vertex(geometry::PointWithAltitude const & junction, + geometry::PointWithAltitude const & stageStart, double stageStartDistance, + size_t stage, bool bearingChecked) : m_junction(junction) , m_stageStart(stageStart) , m_stageStartDistance(stageStartDistance) @@ -174,7 +175,7 @@ bool Router::Init(std::vector<WayPoint> const & points, double positiveOffsetM, m_pivots.emplace_back(); auto & ps = m_pivots.back(); - std::vector<std::pair<routing::Edge, routing::Junction>> vicinity; + std::vector<std::pair<routing::Edge, geometry::PointWithAltitude>> vicinity; m_graph.FindClosestEdges( mercator::RectByCenterXYAndSizeInMeters(m_points[i].m_point, routing::FeaturesRoadGraph::kClosestEdgesRadiusM), @@ -194,8 +195,8 @@ bool Router::Init(std::vector<WayPoint> const & points, double positiveOffsetM, CHECK_EQUAL(m_pivots.size() + 1, m_points.size(), ()); { - m_sourceJunction = routing::Junction(m_points.front().m_point, 0 /* altitude */); - std::vector<std::pair<routing::Edge, routing::Junction>> sourceVicinity; + m_sourceJunction = geometry::PointWithAltitude(m_points.front().m_point, 0 /* altitude */); + std::vector<std::pair<routing::Edge, geometry::PointWithAltitude>> sourceVicinity; m_graph.FindClosestEdges( mercator::RectByCenterXYAndSizeInMeters(m_sourceJunction.GetPoint(), routing::FeaturesRoadGraph::kClosestEdgesRadiusM), @@ -204,8 +205,8 @@ bool Router::Init(std::vector<WayPoint> const & points, double positiveOffsetM, } { - m_targetJunction = routing::Junction(m_points.back().m_point, 0 /* altitude */); - std::vector<std::pair<routing::Edge, routing::Junction>> targetVicinity; + m_targetJunction = geometry::PointWithAltitude(m_points.back().m_point, 0 /* altitude */); + std::vector<std::pair<routing::Edge, geometry::PointWithAltitude>> targetVicinity; m_graph.FindClosestEdges( mercator::RectByCenterXYAndSizeInMeters(m_targetJunction.GetPoint(), routing::FeaturesRoadGraph::kClosestEdgesRadiusM), @@ -452,22 +453,25 @@ void Router::ForEachEdge(Vertex const & u, bool outgoing, FunctionalRoadClass re } } -void Router::GetOutgoingEdges(routing::Junction const & u, routing::IRoadGraph::EdgeVector & edges) +void Router::GetOutgoingEdges(geometry::PointWithAltitude const & u, + routing::IRoadGraph::EdgeVector & edges) { GetEdges(u, &routing::IRoadGraph::GetRegularOutgoingEdges, &routing::IRoadGraph::GetFakeOutgoingEdges, m_outgoingCache, edges); } -void Router::GetIngoingEdges(routing::Junction const & u, routing::IRoadGraph::EdgeVector & edges) +void Router::GetIngoingEdges(geometry::PointWithAltitude const & u, + routing::IRoadGraph::EdgeVector & edges) { GetEdges(u, &routing::IRoadGraph::GetRegularIngoingEdges, &routing::IRoadGraph::GetFakeIngoingEdges, m_ingoingCache, edges); } -void Router::GetEdges(routing::Junction const & u, RoadGraphEdgesGetter getRegular, - RoadGraphEdgesGetter getFake, - std::map<routing::Junction, routing::IRoadGraph::EdgeVector> & cache, - routing::IRoadGraph::EdgeVector & edges) +void Router::GetEdges( + geometry::PointWithAltitude const & u, RoadGraphEdgesGetter getRegular, + RoadGraphEdgesGetter getFake, + std::map<geometry::PointWithAltitude, routing::IRoadGraph::EdgeVector> & cache, + routing::IRoadGraph::EdgeVector & edges) { auto const it = cache.find(u); if (it == cache.end()) @@ -498,7 +502,7 @@ template <typename Fn> void Router::ForEachNonFakeClosestEdge(Vertex const & u, FunctionalRoadClass const restriction, Fn && fn) { - std::vector<std::pair<routing::Edge, routing::Junction>> vicinity; + std::vector<std::pair<routing::Edge, geometry::PointWithAltitude>> vicinity; m_graph.FindClosestEdges( mercator::RectByCenterXYAndSizeInMeters(u.m_junction.GetPoint(), routing::FeaturesRoadGraph::kClosestEdgesRadiusM), diff --git a/openlr/router.hpp b/openlr/router.hpp index 576edc96ad..5435a4ee1c 100644 --- a/openlr/router.hpp +++ b/openlr/router.hpp @@ -73,8 +73,9 @@ private: }; Vertex() = default; - Vertex(routing::Junction const & junction, routing::Junction const & stageStart, - double stageStartDistance, size_t stage, bool bearingChecked); + Vertex(geometry::PointWithAltitude const & junction, + geometry::PointWithAltitude const & stageStart, double stageStartDistance, size_t stage, + bool bearingChecked); bool operator<(Vertex const & rhs) const; bool operator==(Vertex const & rhs) const; @@ -82,8 +83,8 @@ private: m2::PointD GetPoint() const { return m_junction.GetPoint(); } - routing::Junction m_junction; - routing::Junction m_stageStart; + geometry::PointWithAltitude m_junction; + geometry::PointWithAltitude m_stageStart; double m_stageStartDistance = 0.0; size_t m_stage = 0; bool m_bearingChecked = false; @@ -137,7 +138,7 @@ private: using Links = std::map<Vertex, std::pair<Vertex, Edge>>; using RoadGraphEdgesGetter = void (routing::IRoadGraph::*)( - routing::Junction const & junction, routing::IRoadGraph::EdgeVector & edges) const; + geometry::PointWithAltitude const & junction, routing::IRoadGraph::EdgeVector & edges) const; bool Init(std::vector<WayPoint> const & points, double positiveOffsetM, double negativeOffsetM); bool FindPath(std::vector<routing::Edge> & path); @@ -172,11 +173,13 @@ private: template <typename Fn> void ForEachEdge(Vertex const & u, bool outgoing, FunctionalRoadClass restriction, Fn && fn); - void GetOutgoingEdges(routing::Junction const & u, routing::IRoadGraph::EdgeVector & edges); - void GetIngoingEdges(routing::Junction const & u, routing::IRoadGraph::EdgeVector & edges); - void GetEdges(routing::Junction const & u, RoadGraphEdgesGetter getRegular, + void GetOutgoingEdges(geometry::PointWithAltitude const & u, + routing::IRoadGraph::EdgeVector & edges); + void GetIngoingEdges(geometry::PointWithAltitude const & u, + routing::IRoadGraph::EdgeVector & edges); + void GetEdges(geometry::PointWithAltitude const & u, RoadGraphEdgesGetter getRegular, RoadGraphEdgesGetter getFake, - std::map<routing::Junction, routing::IRoadGraph::EdgeVector> & cache, + std::map<geometry::PointWithAltitude, routing::IRoadGraph::EdgeVector> & cache, routing::IRoadGraph::EdgeVector & edges); template <typename Fn> @@ -211,15 +214,15 @@ private: void FindSingleEdgeApproximation(std::vector<Edge> const & edges, std::vector<routing::Edge> & path); routing::FeaturesRoadGraph & m_graph; - std::map<routing::Junction, routing::IRoadGraph::EdgeVector> m_outgoingCache; - std::map<routing::Junction, routing::IRoadGraph::EdgeVector> m_ingoingCache; + std::map<geometry::PointWithAltitude, routing::IRoadGraph::EdgeVector> m_outgoingCache; + std::map<geometry::PointWithAltitude, routing::IRoadGraph::EdgeVector> m_ingoingCache; RoadInfoGetter & m_roadInfoGetter; std::vector<WayPoint> m_points; double m_positiveOffsetM; double m_negativeOffsetM; std::vector<std::vector<m2::PointD>> m_pivots; - routing::Junction m_sourceJunction; - routing::Junction m_targetJunction; + geometry::PointWithAltitude m_sourceJunction; + geometry::PointWithAltitude m_targetJunction; }; } // namespace openlr diff --git a/openlr/score_candidate_paths_getter.cpp b/openlr/score_candidate_paths_getter.cpp index 900cd48e5a..5491163277 100644 --- a/openlr/score_candidate_paths_getter.cpp +++ b/openlr/score_candidate_paths_getter.cpp @@ -10,6 +10,7 @@ #include "geometry/angles.hpp" #include "geometry/mercator.hpp" +#include "geometry/point_with_altitude.hpp" #include "base/logging.hpp" #include "base/stl_helpers.hpp" @@ -66,7 +67,7 @@ Graph::Edge ScoreCandidatePathsGetter::Link::GetStartEdge() const return start->m_edge; } -bool ScoreCandidatePathsGetter::Link::IsJunctionInPath(Junction const & j) const +bool ScoreCandidatePathsGetter::Link::IsJunctionInPath(geometry::PointWithAltitude const & j) const { for (auto * l = this; l; l = l->m_parent.get()) { diff --git a/openlr/score_candidate_paths_getter.hpp b/openlr/score_candidate_paths_getter.hpp index ccf1c10ef2..e453938e3a 100644 --- a/openlr/score_candidate_paths_getter.hpp +++ b/openlr/score_candidate_paths_getter.hpp @@ -47,7 +47,7 @@ private: CHECK(!edge.IsFake(), ("Edge should not be fake:", edge)); } - bool IsJunctionInPath(routing::Junction const & j) const; + bool IsJunctionInPath(geometry::PointWithAltitude const & j) const; Graph::Edge GetStartEdge() const; diff --git a/openlr/score_candidate_points_getter.cpp b/openlr/score_candidate_points_getter.cpp index 249500aa1e..a256c3f5cc 100644 --- a/openlr/score_candidate_points_getter.cpp +++ b/openlr/score_candidate_points_getter.cpp @@ -11,6 +11,7 @@ #include "indexer/scales.hpp" #include "geometry/mercator.hpp" +#include "geometry/point_with_altitude.hpp" #include "base/assert.hpp" #include "base/stl_helpers.hpp" @@ -55,9 +56,9 @@ void ScoreCandidatePointsGetter::GetJunctionPointCandidates(m2::PointD const & p { Graph::EdgeVector edges; if (!isLastPoint) - m_graph.GetOutgoingEdges(Junction(pc.m_point, 0 /* altitude */), edges); + m_graph.GetOutgoingEdges(geometry::PointWithAltitude(pc.m_point, 0 /* altitude */), edges); else - m_graph.GetIngoingEdges(Junction(pc.m_point, 0 /* altitude */), edges); + m_graph.GetIngoingEdges(geometry::PointWithAltitude(pc.m_point, 0 /* altitude */), edges); for (auto const & e : edges) edgeCandidates.emplace_back(pc.m_score, e); @@ -69,7 +70,7 @@ void ScoreCandidatePointsGetter::EnrichWithProjectionPoints(m2::PointD const & p { m_graph.ResetFakes(); - std::vector<std::pair<Graph::Edge, Junction>> vicinities; + std::vector<std::pair<Graph::Edge, geometry::PointWithAltitude>> vicinities; m_graph.FindClosestEdges(p, static_cast<uint32_t>(m_maxProjectionCandidates), vicinities); for (auto const & v : vicinities) { @@ -89,10 +90,10 @@ void ScoreCandidatePointsGetter::EnrichWithProjectionPoints(m2::PointD const & p bool ScoreCandidatePointsGetter::IsJunction(m2::PointD const & p) { Graph::EdgeVector outgoing; - m_graph.GetRegularOutgoingEdges(Junction(p, 0 /* altitude */), outgoing); + m_graph.GetRegularOutgoingEdges(geometry::PointWithAltitude(p, 0 /* altitude */), outgoing); Graph::EdgeVector ingoing; - m_graph.GetRegularIngoingEdges(Junction(p, 0 /* altitude */), ingoing); + m_graph.GetRegularIngoingEdges(geometry::PointWithAltitude(p, 0 /* altitude */), ingoing); // Note. At mwm borders the size of |ids| may be bigger than two in case of straight // road because of road feature duplication at borders. |