From 789efa1eb16fc3f9fd3f09f9e59c2654e577e8e9 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Wed, 4 Dec 2019 09:25:57 +0300 Subject: [PATCH] [routing] Renaming point to checkpoint in methods which looking for the closest segemnt and edge. --- routing/index_router.cpp | 50 ++++++++++++++++++++-------------------- routing/index_router.hpp | 16 ++++++------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/routing/index_router.cpp b/routing/index_router.cpp index 57f9eeff93..36c8f2c543 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -313,12 +313,12 @@ unique_ptr IndexRouter::MakeSingleMwmWorldGraph() return worldGraph; } -bool IndexRouter::FindBestSegments(m2::PointD const & point, m2::PointD const & direction, +bool IndexRouter::FindBestSegments(m2::PointD const & checkpoint, m2::PointD const & direction, bool isOutgoing, WorldGraph & worldGraph, vector & bestSegments) { bool dummy; - return FindBestSegments(point, direction, isOutgoing, worldGraph, bestSegments, + return FindBestSegments(checkpoint, direction, isOutgoing, worldGraph, bestSegments, dummy /* best segment is almost codirectional */); } @@ -795,21 +795,21 @@ unique_ptr IndexRouter::MakeWorldGraph() move(transitGraphLoader), m_estimator); } -void IndexRouter::EraseIfDeadEnd(WorldGraph & worldGraph, m2::PointD const & point, +void IndexRouter::EraseIfDeadEnd(WorldGraph & worldGraph, m2::PointD const & checkpoint, vector & roads) const { // |deadEnds| cache is necessary to minimize number of calls a time consumption IsDeadEnd() method. set deadEnds; - base::EraseIf(roads, [&deadEnds, &worldGraph, &point, this](auto const & fullRoadInfo) { + base::EraseIf(roads, [&deadEnds, &worldGraph, &checkpoint, this](auto const & fullRoadInfo) { CHECK_GREATER_OR_EQUAL(fullRoadInfo.m_roadInfo.m_junctions.size(), 2, ()); auto const squaredDistAndIndex = m2::CalcMinSquaredDistance(fullRoadInfo.m_roadInfo.m_junctions.begin(), fullRoadInfo.m_roadInfo.m_junctions.end(), - point); + checkpoint); auto const segmentId = squaredDistAndIndex.second; // Note. Checking if an edge goes to a dead end is a time consumption process. // So the number of checked edges should be minimized as possible. - // Below a heuristic is used. If the closest to |point| segment of a feature + // Below a heuristic is used. If the closest to |checkpoint| segment of a feature // in forward direction is a dead end all segments of the feature is considered as dead ends. auto const segment = GetSegmentByEdge(Edge::MakeReal(fullRoadInfo.m_featureId, true /* forward */, segmentId, @@ -906,22 +906,22 @@ bool IndexRouter::FindClosestCodirectionalEdge( return squareDistToClosestCodirectionalEdgeM != kInvalidDist; } -bool IndexRouter::FindBestSegments(m2::PointD const & point, m2::PointD const & direction, +bool IndexRouter::FindBestSegments(m2::PointD const & checkpoint, m2::PointD const & direction, bool isOutgoing, WorldGraph & worldGraph, vector & bestSegments, bool & bestSegmentIsAlmostCodirectional) const { - auto const file = platform::CountryFile(m_countryFileFn(point)); + auto const file = platform::CountryFile(m_countryFileFn(checkpoint)); vector bestEdges; - if (!FindBestEdges(point, file, direction, isOutgoing, 40.0 /* closestEdgesRadiusM */, + if (!FindBestEdges(checkpoint, file, direction, isOutgoing, 40.0 /* closestEdgesRadiusM */, worldGraph, bestEdges, bestSegmentIsAlmostCodirectional)) { - if (!FindBestEdges(point, file, direction, isOutgoing, 500.0 /* closestEdgesRadiusM */, + if (!FindBestEdges(checkpoint, file, direction, isOutgoing, 500.0 /* closestEdgesRadiusM */, worldGraph, bestEdges, bestSegmentIsAlmostCodirectional) && bestEdges.size() < kMaxRoadCandidates) { - if (!FindBestEdges(point, file, direction, isOutgoing, 2000.0 /* closestEdgesRadiusM */, + if (!FindBestEdges(checkpoint, file, direction, isOutgoing, 2000.0 /* closestEdgesRadiusM */, worldGraph, bestEdges, bestSegmentIsAlmostCodirectional)) { return false; @@ -936,7 +936,7 @@ bool IndexRouter::FindBestSegments(m2::PointD const & point, m2::PointD const & return true; } -bool IndexRouter::FindBestEdges(m2::PointD const & point, +bool IndexRouter::FindBestEdges(m2::PointD const & checkpoint, platform::CountryFile const & pointCountryFile, m2::PointD const & direction, bool isOutgoing, double closestEdgesRadiusM, WorldGraph & worldGraph, @@ -948,7 +948,7 @@ bool IndexRouter::FindBestEdges(m2::PointD const & point, if (!handle.IsAlive()) MYTHROW(MwmIsNotAliveException, ("Can't get mwm handle for", pointCountryFile)); - auto const rect = mercator::RectByCenterXYAndSizeInMeters(point, closestEdgesRadiusM); + auto const rect = mercator::RectByCenterXYAndSizeInMeters(checkpoint, closestEdgesRadiusM); auto const isGoodFeature = [this](FeatureID const & fid) { auto const & info = fid.m_mwmId.GetInfo(); return m_numMwmIds->ContainsFile(info->GetLocalFile().GetCountryFile()); @@ -957,20 +957,20 @@ bool IndexRouter::FindBestEdges(m2::PointD const & point, // Removing all dead ends from |closestRoads|. Then some candidates will be taken from |closestRoads|. // It's necessary to remove all dead ends for all |closestRoads| before IsFencedOff(). - // If to remove all fenced off by other features from |point| candidates at first, + // If to remove all fenced off by other features from |checkpoint| candidates at first, // only dead ends candidates may be left. And then the dead end candidates will be removed // as well as dead ends. It often happens near airports. - EraseIfDeadEnd(worldGraph, point, closestRoads); + EraseIfDeadEnd(worldGraph, checkpoint, closestRoads); // Sorting from the closest features to the further ones. The idea is the closer - // a feature to a |point| the more chances that it crosses the segment - // |point|, projections of |point| on feature edges. It confirmed with benchmarks. + // a feature to a |checkpoint| the more chances that it crosses the segment + // |checkpoint|, projections of |checkpoint| on feature edges. It confirmed with benchmarks. sort(closestRoads.begin(), closestRoads.end(), - [&point](IRoadGraph::FullRoadInfo const & lhs, IRoadGraph::FullRoadInfo const & rhs) { + [&checkpoint](IRoadGraph::FullRoadInfo const & lhs, IRoadGraph::FullRoadInfo const & rhs) { CHECK(!lhs.m_roadInfo.m_junctions.empty(), ()); return - point.SquaredLength(lhs.m_roadInfo.m_junctions[0].GetPoint()) < - point.SquaredLength(rhs.m_roadInfo.m_junctions[0].GetPoint()); + checkpoint.SquaredLength(lhs.m_roadInfo.m_junctions[0].GetPoint()) < + checkpoint.SquaredLength(rhs.m_roadInfo.m_junctions[0].GetPoint()); }); // Note about necessity of removing dead ends twice. @@ -988,22 +988,22 @@ bool IndexRouter::FindBestEdges(m2::PointD const & point, if (IsDeadEndCached(segment, isOutgoing, true /* useRoutingOptions */, worldGraph, deadEnds)) return false; - // Removing all candidates which are fenced off by the road graph (|closestRoads|) from |point|. - return !IsFencedOff(point, edgeProj, closestRoads); + // Removing all candidates which are fenced off by the road graph (|closestRoads|) from |checkpoint|. + return !IsFencedOff(checkpoint, edgeProj, closestRoads); }; // Getting closest edges from |closestRoads| if they are correct according to isGood() function. vector> candidates; - RoadsToNearestEdges(point, closestRoads, isGood, candidates); + RoadsToNearestEdges(checkpoint, closestRoads, isGood, candidates); if (candidates.empty()) return false; // Looking for the closest codirectional edge. If it's not found add all good candidates. Edge closestCodirectionalEdge; - BestEdgeComparator bestEdgeComparator(point, direction); + BestEdgeComparator bestEdgeComparator(checkpoint, direction); bestSegmentIsAlmostCodirectional = - FindClosestCodirectionalEdge(point, direction, candidates, closestCodirectionalEdge); + FindClosestCodirectionalEdge(checkpoint, direction, candidates, closestCodirectionalEdge); if (bestSegmentIsAlmostCodirectional) { diff --git a/routing/index_router.hpp b/routing/index_router.hpp index bad5fd3c40..d4b6868a50 100644 --- a/routing/index_router.hpp +++ b/routing/index_router.hpp @@ -77,9 +77,9 @@ public: traffic::TrafficCache const & trafficCache, DataSource & dataSource); std::unique_ptr MakeSingleMwmWorldGraph(); - bool FindBestSegments(m2::PointD const & point, m2::PointD const & direction, bool isOutgoing, + bool FindBestSegments(m2::PointD const & checkpoint, m2::PointD const & direction, bool isOutgoing, WorldGraph & worldGraph, std::vector & bestSegments); - bool FindBestEdges(m2::PointD const & point, + bool FindBestEdges(m2::PointD const & checkpoint, platform::CountryFile const & pointCountryFile, m2::PointD const & direction, bool isOutgoing, double closestEdgesRadiusM, WorldGraph & worldGraph, @@ -126,9 +126,9 @@ private: /// \brief Removes all roads from |roads| which goes to dead ends and all road which /// is not good according to |worldGraph|. For car routing there are roads with hwtag nocar as well. - /// \param point which is used to look for the closest segment in a road. The closest segment + /// \param checkpoint which is used to look for the closest segment in a road. The closest segment /// is used then to check if it's a dead end. - void EraseIfDeadEnd(WorldGraph & worldGraph, m2::PointD const & point, + void EraseIfDeadEnd(WorldGraph & worldGraph, m2::PointD const & checkpoint, std::vector & roads) const; /// \returns true if a segment (|point|, |edgeProjection.second|) crosses one of segments @@ -152,17 +152,17 @@ private: Edge & closestCodirectionalEdge) const; /// \brief Finds the best segments (edges) which may be considered as starts or finishes - /// of the route. According to current implementation the closest to |point| segment which + /// of the route. According to current implementation the closest to |checkpoint| segment which /// is almost codirectianal to |direction| is the best. /// If there's no an almost codirectional segment in the neighbourhood then all not dead end /// candidates which may be reached without crossing road graph will be added to |bestSegments|. - /// \param isOutgoing == true if |point| is considered as the start of the route. - /// isOutgoing == false if |point| is considered as the finish of the route. + /// \param isOutgoing == true if |checkpoint| is considered as the start of the route. + /// isOutgoing == false if |checkpoint| is considered as the finish of the route. /// \param bestSegmentIsAlmostCodirectional is filled with true if |bestSegment| is chosen /// because |direction| and direction of |bestSegment| are almost equal and with false otherwise. /// \return true if the best segment is found and false otherwise. /// \note Candidates in |bestSegments| are sorted from better to worse. - bool FindBestSegments(m2::PointD const & point, m2::PointD const & direction, bool isOutgoing, + bool FindBestSegments(m2::PointD const & checkpoint, m2::PointD const & direction, bool isOutgoing, WorldGraph & worldGraph, std::vector & bestSegments, bool & bestSegmentIsAlmostCodirectional) const;