From 7616a0d2605a2739e1c2d937a084b25520e377e3 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Fri, 20 Jan 2017 10:53:58 +0300 Subject: [PATCH] Review fixes. --- routing/geometry.hpp | 5 +++++ routing/index_graph.cpp | 9 ++++----- routing/index_graph.hpp | 3 +-- routing/restriction_loader.cpp | 5 +++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/routing/geometry.hpp b/routing/geometry.hpp index c172f4cf88..af7acd9f4b 100644 --- a/routing/geometry.hpp +++ b/routing/geometry.hpp @@ -42,6 +42,11 @@ public: // In such cases RoadGeometry is not valid. bool IsValid() const { return m_valid; } + bool IsEndPointId(uint32_t pointId) const + { + return pointId == 0 || pointId + 1 == GetPointsCount(); + } + private: Points m_points; double m_speed = 0.0; diff --git a/routing/index_graph.cpp b/routing/index_graph.cpp index e373612ac6..328ebdbda5 100644 --- a/routing/index_graph.cpp +++ b/routing/index_graph.cpp @@ -37,7 +37,7 @@ bool IsRestricted(RestrictionVec const & restrictions, Segment const & u, Segmen // where the U-turn is restricted. It's necessary to pass the data to mwm and to use it here. // Please see test LineGraph_RestrictionF1F1No for details. // - // Another exapmle when it's necessary to be aware about feature end particepated in restriction + // Another example when it's necessary to be aware about feature end participated in restriction // is // *---F1---* // | | @@ -129,9 +129,8 @@ void IndexGraph::GetNeighboringEdge(Segment const & from, Segment const & to, bo { // Blocking U-turns on internal feature points. RoadPoint const rp = from.GetRoadPoint(isOutgoing); - if (IsUTurn(from, to) && m_roadIndex.GetJointId(rp) == Joint::kInvalidId && - rp.GetPointId() != 0 && - rp.GetPointId() + 1 != m_geometry.GetRoad(from.GetFeatureId()).GetPointsCount()) + if (IsUTurn(from, to) && m_roadIndex.GetJointId(rp) == Joint::kInvalidId + && !m_geometry.GetRoad(from.GetFeatureId()).IsEndPointId(rp.GetPointId())) { return; } @@ -145,7 +144,7 @@ void IndexGraph::GetNeighboringEdge(Segment const & from, Segment const & to, bo edges.emplace_back(to, weight); } -double IndexGraph::GetPenalties(Segment const & u, Segment const & v) +double IndexGraph::GetPenalties(Segment const & u, Segment const & v) const { if (IsUTurn(u, v)) return GetEstimator().GetUTurnPenalty(); diff --git a/routing/index_graph.hpp b/routing/index_graph.hpp index 6c218b789e..ddcf96e688 100644 --- a/routing/index_graph.hpp +++ b/routing/index_graph.hpp @@ -67,13 +67,12 @@ private: vector & edges); void GetNeighboringEdge(Segment const & from, Segment const & to, bool isOutgoing, vector & edges); - double GetPenalties(Segment const & u, Segment const & v); + double GetPenalties(Segment const & u, Segment const & v) const; Geometry m_geometry; shared_ptr m_estimator; RoadIndex m_roadIndex; JointIndex m_jointIndex; - RestrictionVec m_restrictions; }; } // namespace routing diff --git a/routing/restriction_loader.cpp b/routing/restriction_loader.cpp index 5f2e781758..bee841182b 100644 --- a/routing/restriction_loader.cpp +++ b/routing/restriction_loader.cpp @@ -9,8 +9,8 @@ namespace using namespace routing; /// \returns if features |r1| and |r2| have a common end returns its joint id. -/// If not, returnfs Joint::kInvalidId. -/// \note It's possible that the both ends of |r1| and |r2| has common joint ids. +/// If not, returns Joint::kInvalidId. +/// \note It's possible that the both ends of |r1| and |r2| have common joint ids. /// In that case returns any of them. /// \note In general case ends of features don't have to be joints. For example all /// loose feature ends aren't joints. But if ends of r1 and r2 are connected at this @@ -61,6 +61,7 @@ RestrictionLoader::RestrictionLoader(MwmValue const & mwmValue, IndexGraph const m_header.Reset(); LOG(LERROR, ("File", m_countryFileName, "Error while reading", RESTRICTIONS_FILE_TAG, "section.", e.Msg())); + throw; } }