From f9991d7c32956467237845f90e8e8ed8a48867b3 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Tue, 21 May 2019 15:43:10 +0300 Subject: [PATCH] Review fixes. --- openlr/score_candidate_paths_getter.cpp | 49 +++++++++++++------------ openlr/score_candidate_paths_getter.hpp | 10 ++--- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/openlr/score_candidate_paths_getter.cpp b/openlr/score_candidate_paths_getter.cpp index 1967eca582..6c9d0483d3 100644 --- a/openlr/score_candidate_paths_getter.cpp +++ b/openlr/score_candidate_paths_getter.cpp @@ -56,30 +56,6 @@ double DifferenceInDeg(double a1, double a2) } } // namespace -bool GetBearingScore(BearingPointsSelector const & pointsSelector, - ScoreCandidatePathsGetter::Link const & part, - m2::PointD const & bearStartPoint, uint32_t requiredBearing, Score & score) -{ - auto const bearEndPoint = pointsSelector.GetEndPoint(part.m_edge, part.m_distanceM); - - auto const bearingDeg = BearingInDeg(bearStartPoint, bearEndPoint); - double const requiredBearingDeg = ToAngleInDeg(requiredBearing); - double const angleDeviationDeg = DifferenceInDeg(bearingDeg, requiredBearingDeg); - - // If the bearing according to osm segments (|bearingDeg|) is significantly different - // from the bearing set in openlr (|requiredBearingDeg|) the candidate should be skipped. - double constexpr kMinAngleDeviationDeg = 50.0; - if (angleDeviationDeg > kMinAngleDeviationDeg) - return false; - - double constexpr kMaxScoreForBearing = 60.0; - double constexpr kAngleDeviationFactor = 1.0 / 4.3; - score = - static_cast(kMaxScoreForBearing / (1.0 + angleDeviationDeg * kAngleDeviationFactor)); - - return true; -} - // ScoreCandidatePathsGetter::Link ---------------------------------------------------------------------- Graph::Edge ScoreCandidatePathsGetter::Link::GetStartEdge() const { @@ -314,4 +290,29 @@ void ScoreCandidatePathsGetter::GetLineCandidates(openlr::LocationReferencePoint [](ScorePath const & s1, ScorePath const & s2) { return s1.m_score > s2.m_score; }); LOG(LDEBUG, (candidates.size(), "Candidate paths found for point:", p.m_latLon)); } + +bool ScoreCandidatePathsGetter::GetBearingScore(BearingPointsSelector const & pointsSelector, + ScoreCandidatePathsGetter::Link const & part, + m2::PointD const & bearStartPoint, + uint32_t requiredBearing, Score & score) +{ + auto const bearEndPoint = pointsSelector.GetEndPoint(part.m_edge, part.m_distanceM); + + auto const bearingDeg = BearingInDeg(bearStartPoint, bearEndPoint); + double const requiredBearingDeg = ToAngleInDeg(requiredBearing); + double const angleDeviationDeg = DifferenceInDeg(bearingDeg, requiredBearingDeg); + + // If the bearing according to osm segments (|bearingDeg|) is significantly different + // from the bearing set in openlr (|requiredBearingDeg|) the candidate should be skipped. + double constexpr kMinAngleDeviationDeg = 50.0; + if (angleDeviationDeg > kMinAngleDeviationDeg) + return false; + + double constexpr kMaxScoreForBearing = 60.0; + double constexpr kAngleDeviationFactor = 1.0 / 4.3; + score = + static_cast(kMaxScoreForBearing / (1.0 + angleDeviationDeg * kAngleDeviationFactor)); + + return true; +} } // namespace openlr diff --git a/openlr/score_candidate_paths_getter.hpp b/openlr/score_candidate_paths_getter.hpp index acf29ef360..ccf1c10ef2 100644 --- a/openlr/score_candidate_paths_getter.hpp +++ b/openlr/score_candidate_paths_getter.hpp @@ -22,12 +22,6 @@ class ScoreCandidatePointsGetter; class ScoreCandidatePathsGetter { - struct Link; - friend bool GetBearingScore(BearingPointsSelector const & pointsSelector, - ScoreCandidatePathsGetter::Link const & part, - m2::PointD const & bearStartPoint, uint32_t requiredBearing, - Score & score); - public: ScoreCandidatePathsGetter(ScoreCandidatePointsGetter & pointsGetter, Graph & graph, RoadInfoGetter & infoGetter, v2::Stats & stat) @@ -117,6 +111,10 @@ private: bool isLastPoint, double distanceToNextPointM, ScoreEdgeVec const & edgeCandidates, ScorePathVec & candidates); + bool GetBearingScore(BearingPointsSelector const & pointsSelector, + ScoreCandidatePathsGetter::Link const & part, + m2::PointD const & bearStartPoint, uint32_t requiredBearing, Score & score); + ScoreCandidatePointsGetter & m_pointsGetter; Graph & m_graph; RoadInfoGetter & m_infoGetter;