From a691705e307c1b8edb76b75ce8645b9849eff984 Mon Sep 17 00:00:00 2001 From: tatiana-kondakova Date: Fri, 12 Jan 2018 12:58:41 +0300 Subject: [PATCH] Rename routing::RouteWeight::m_nonPassThrougCross to m_numPassThroughChanges --- routing/index_graph_starter.cpp | 6 +++--- routing/route_weight.cpp | 28 ++++++++++++------------- routing/route_weight.hpp | 36 ++++++++++++++++----------------- routing/transit_graph.cpp | 4 ++-- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/routing/index_graph_starter.cpp b/routing/index_graph_starter.cpp index cbe1689cda..0050851ec2 100644 --- a/routing/index_graph_starter.cpp +++ b/routing/index_graph_starter.cpp @@ -131,12 +131,12 @@ set IndexGraphStarter::GetMwms() const bool IndexGraphStarter::CheckLength(RouteWeight const & weight) { - // We allow 1 pass-through/non-pass-through crossing per ending located in + // We allow 1 pass-through/non-pass-through zone changes per ending located in // non-pass-through zone to allow user to leave this zone. - int32_t const nonPassThroughCrossAllowed = + int32_t const numPassThroughChangesAllowed = (StartPassThroughAllowed() ? 0 : 1) + (FinishPassThroughAllowed() ? 0 : 1); - return weight.GetNonPassThroughCross() <= nonPassThroughCrossAllowed && + return weight.GetNumPassThroughChanges() <= numPassThroughChangesAllowed && m_graph.CheckLength(weight, m_startToFinishDistanceM); } diff --git a/routing/route_weight.cpp b/routing/route_weight.cpp index 976e29174c..f4ade713ab 100644 --- a/routing/route_weight.cpp +++ b/routing/route_weight.cpp @@ -24,43 +24,43 @@ namespace routing { double RouteWeight::ToCrossMwmWeight() const { - if (m_nonPassThroughCross > 0 || m_numAccessChanges > 0) + if (m_numPassThroughChanges > 0 || m_numAccessChanges > 0) return connector::kNoRoute; return GetWeight(); } RouteWeight RouteWeight::operator+(RouteWeight const & rhs) const { - ASSERT(!SumWillOverflow(m_nonPassThroughCross, rhs.m_nonPassThroughCross), - (m_nonPassThroughCross, rhs.m_nonPassThroughCross)); + ASSERT(!SumWillOverflow(m_numPassThroughChanges, rhs.m_numPassThroughChanges), + (m_numPassThroughChanges, rhs.m_numPassThroughChanges)); ASSERT(!SumWillOverflow(m_numAccessChanges, rhs.m_numAccessChanges), (m_numAccessChanges, rhs.m_numAccessChanges)); - return RouteWeight(m_weight + rhs.m_weight, m_nonPassThroughCross + rhs.m_nonPassThroughCross, + return RouteWeight(m_weight + rhs.m_weight, m_numPassThroughChanges + rhs.m_numPassThroughChanges, m_numAccessChanges + rhs.m_numAccessChanges, m_transitTime + rhs.m_transitTime); } RouteWeight RouteWeight::operator-(RouteWeight const & rhs) const { - ASSERT_NOT_EQUAL(m_nonPassThroughCross, std::numeric_limits::min(), ()); + ASSERT_NOT_EQUAL(m_numPassThroughChanges, std::numeric_limits::min(), ()); ASSERT_NOT_EQUAL(m_numAccessChanges, std::numeric_limits::min(), ()); - ASSERT(!SumWillOverflow(m_nonPassThroughCross, -rhs.m_nonPassThroughCross), - (m_nonPassThroughCross, -rhs.m_nonPassThroughCross)); + ASSERT(!SumWillOverflow(m_numPassThroughChanges, -rhs.m_numPassThroughChanges), + (m_numPassThroughChanges, -rhs.m_numPassThroughChanges)); ASSERT(!SumWillOverflow(m_numAccessChanges, -rhs.m_numAccessChanges), (m_numAccessChanges, -rhs.m_numAccessChanges)); - return RouteWeight(m_weight - rhs.m_weight, m_nonPassThroughCross - rhs.m_nonPassThroughCross, + return RouteWeight(m_weight - rhs.m_weight, m_numPassThroughChanges - rhs.m_numPassThroughChanges, m_numAccessChanges - rhs.m_numAccessChanges, m_transitTime - rhs.m_transitTime); } RouteWeight & RouteWeight::operator+=(RouteWeight const & rhs) { - ASSERT(!SumWillOverflow(m_nonPassThroughCross, rhs.m_nonPassThroughCross), - (m_nonPassThroughCross, rhs.m_nonPassThroughCross)); + ASSERT(!SumWillOverflow(m_numPassThroughChanges, rhs.m_numPassThroughChanges), + (m_numPassThroughChanges, rhs.m_numPassThroughChanges)); ASSERT(!SumWillOverflow(m_numAccessChanges, rhs.m_numAccessChanges), (m_numAccessChanges, rhs.m_numAccessChanges)); m_weight += rhs.m_weight; - m_nonPassThroughCross += rhs.m_nonPassThroughCross; + m_numPassThroughChanges += rhs.m_numPassThroughChanges; m_numAccessChanges += rhs.m_numAccessChanges; m_transitTime += rhs.m_transitTime; return *this; @@ -68,14 +68,14 @@ RouteWeight & RouteWeight::operator+=(RouteWeight const & rhs) ostream & operator<<(ostream & os, RouteWeight const & routeWeight) { - os << "(" << routeWeight.GetNonPassThroughCross() << ", " << routeWeight.GetNumAccessChanges() + os << "(" << routeWeight.GetNumPassThroughChanges() << ", " << routeWeight.GetNumAccessChanges() << ", " << routeWeight.GetWeight() << ", " << routeWeight.GetTransitTime() << ")"; return os; } RouteWeight operator*(double lhs, RouteWeight const & rhs) { - return RouteWeight(lhs * rhs.GetWeight(), rhs.GetNonPassThroughCross(), rhs.GetNumAccessChanges(), - lhs * rhs.GetTransitTime()); + return RouteWeight(lhs * rhs.GetWeight(), rhs.GetNumPassThroughChanges(), + rhs.GetNumAccessChanges(), lhs * rhs.GetTransitTime()); } } // namespace routing diff --git a/routing/route_weight.hpp b/routing/route_weight.hpp index 8cd12ec9da..1d057cc269 100644 --- a/routing/route_weight.hpp +++ b/routing/route_weight.hpp @@ -17,10 +17,10 @@ public: explicit constexpr RouteWeight(double weight) : m_weight(weight) {} - constexpr RouteWeight(double weight, int32_t nonPassThroughCross, int32_t numAccessChanges, + constexpr RouteWeight(double weight, int32_t numPassThroughChanges, int32_t numAccessChanges, double transitTime) : m_weight(weight) - , m_nonPassThroughCross(nonPassThroughCross) + , m_numPassThroughChanges(numPassThroughChanges) , m_numAccessChanges(numAccessChanges) , m_transitTime(transitTime) { @@ -30,17 +30,17 @@ public: double ToCrossMwmWeight() const; double GetWeight() const { return m_weight; } - int32_t GetNonPassThroughCross() const { return m_nonPassThroughCross; } + int32_t GetNumPassThroughChanges() const { return m_numPassThroughChanges; } int32_t GetNumAccessChanges() const { return m_numAccessChanges; } double GetTransitTime() const { return m_transitTime; } bool operator<(RouteWeight const & rhs) const { - if (m_nonPassThroughCross != rhs.m_nonPassThroughCross) - return m_nonPassThroughCross < rhs.m_nonPassThroughCross; - // We compare m_numAccessChanges after m_nonPassThroughCross because we can have multiple nodes - // with access tags on the way from the area with limited access and no access tags on the ways - // inside this area. So we probably need to make access restriction less strict than pass + if (m_numPassThroughChanges != rhs.m_numPassThroughChanges) + return m_numPassThroughChanges < rhs.m_numPassThroughChanges; + // We compare m_numAccessChanges after m_numPassThroughChanges because we can have multiple + // nodes with access tags on the way from the area with limited access and no access tags on the + // ways inside this area. So we probably need to make access restriction less strict than pass // through restrictions e.g. allow to cross access={private, destination} and build the route // with the least possible number of such crosses or introduce some maximal number of // access={private, destination} crosses. @@ -70,28 +70,28 @@ public: RouteWeight operator-() const { - ASSERT_NOT_EQUAL(m_nonPassThroughCross, std::numeric_limits::min(), ()); + ASSERT_NOT_EQUAL(m_numPassThroughChanges, std::numeric_limits::min(), ()); ASSERT_NOT_EQUAL(m_numAccessChanges, std::numeric_limits::min(), ()); - return RouteWeight(-m_weight, -m_nonPassThroughCross, -m_numAccessChanges, -m_transitTime); + return RouteWeight(-m_weight, -m_numPassThroughChanges, -m_numAccessChanges, -m_transitTime); } bool IsAlmostEqualForTests(RouteWeight const & rhs, double epsilon) { - return m_nonPassThroughCross == rhs.m_nonPassThroughCross && + return m_numPassThroughChanges == rhs.m_numPassThroughChanges && m_numAccessChanges == rhs.m_numAccessChanges && my::AlmostEqualAbs(m_weight, rhs.m_weight, epsilon) && my::AlmostEqualAbs(m_transitTime, rhs.m_transitTime, epsilon); } private: - // Note: consider smaller types for m_nonPassThroughCross and m_numAccessChanges + // Note: consider smaller types for m_numPassThroughChanges and m_numAccessChanges // in case of adding new fields to RouteWeight to reduce RouteWeight size. // Regular weight (seconds). double m_weight = 0.0; - // Number of pass-through/non-pass-through area border crosses. - int32_t m_nonPassThroughCross = 0; - // Number of access=yes/access={private,destination} area border crosses. + // Number of pass-through/non-pass-through zone changes. + int32_t m_numPassThroughChanges = 0; + // Number of access=yes/access={private,destination} zone changes. int32_t m_numAccessChanges = 0; // Transit time. It's already included in |m_weight| (m_transitTime <= m_weight). double m_transitTime = 0.0; @@ -105,7 +105,7 @@ template <> constexpr RouteWeight GetAStarWeightMax() { return RouteWeight(std::numeric_limits::max() /* weight */, - std::numeric_limits::max() /* nonPassThroughCross */, + std::numeric_limits::max() /* numPassThroughChanges */, std::numeric_limits::max() /* numAccessChanges */, 0 /* transitTime */); // operator< prefers bigger transit time } @@ -113,14 +113,14 @@ constexpr RouteWeight GetAStarWeightMax() template <> constexpr RouteWeight GetAStarWeightZero() { - return RouteWeight(0.0 /* weight */, 0 /* nonPassThroughCross */, 0 /* numAccessChanges */, + return RouteWeight(0.0 /* weight */, 0 /* numPassThroughChanges */, 0 /* numAccessChanges */, 0.0 /* transitTime */); } template <> constexpr RouteWeight GetAStarWeightEpsilon() { - return RouteWeight(GetAStarWeightEpsilon(), 0 /* nonPassThroughCross */, + return RouteWeight(GetAStarWeightEpsilon(), 0 /* numPassThroughChanges */, 0 /* numAccessChanges */, 0.0 /* transitTime */); } diff --git a/routing/transit_graph.cpp b/routing/transit_graph.cpp index 2cdf384795..5f745adb79 100644 --- a/routing/transit_graph.cpp +++ b/routing/transit_graph.cpp @@ -56,14 +56,14 @@ RouteWeight TransitGraph::CalcSegmentWeight(Segment const & segment) const if (IsGate(segment)) { auto const weight = GetGate(segment).GetWeight(); - return RouteWeight(weight /* weight */, 0 /* nonPassThroughCross */, 0 /* numAccessChanges */, + return RouteWeight(weight /* weight */, 0 /* numPassThroughChanges */, 0 /* numAccessChanges */, weight /* transitTime */); } if (IsEdge(segment)) { auto const weight = GetEdge(segment).GetWeight(); - return RouteWeight(weight /* weight */, 0 /* nonPassThrougCross */, 0 /* numAccessChanges */, + return RouteWeight(weight /* weight */, 0 /* numPassThroughChanges */, 0 /* numAccessChanges */, weight /* transitTime */); }