From e03e986c71969db0d3d5b625224368715252c6e8 Mon Sep 17 00:00:00 2001 From: tatiana-kondakova Date: Thu, 16 Nov 2017 19:12:21 +0300 Subject: [PATCH] Rename IsTransitAllowed -> IsPassThroughAllowed because we use "Transit" for public transport --- routing/features_road_graph.cpp | 4 +-- routing/features_road_graph.hpp | 2 +- routing/geometry.cpp | 2 +- routing/geometry.hpp | 9 +++-- routing/index_graph.cpp | 14 ++++---- routing/index_graph_starter.cpp | 20 +++++------ routing/index_graph_starter.hpp | 8 ++--- routing/index_router.cpp | 9 ++--- routing/road_access.hpp | 2 +- routing/route_weight.cpp | 6 ++-- routing/route_weight.hpp | 30 ++++++++-------- routing/routing_tests/index_graph_tools.cpp | 8 ++--- routing/routing_tests/index_graph_tools.hpp | 2 +- routing/routing_tests/restriction_test.cpp | 35 ++++++++++--------- routing/single_vehicle_world_graph.cpp | 14 ++++---- routing/single_vehicle_world_graph.hpp | 2 +- routing/transit_world_graph.cpp | 4 +-- routing/transit_world_graph.hpp | 4 +-- routing/world_graph.hpp | 6 ++-- routing_common/bicycle_model.cpp | 6 ++-- routing_common/car_model.cpp | 22 ++++++------ routing_common/pedestrian_model.cpp | 2 +- .../vehicle_model_test.cpp | 14 ++++---- routing_common/vehicle_model.cpp | 14 ++++---- routing_common/vehicle_model.hpp | 26 ++++++++------ 25 files changed, 136 insertions(+), 129 deletions(-) diff --git a/routing/features_road_graph.cpp b/routing/features_road_graph.cpp index c7ef7ec604..ea5cdd7b09 100644 --- a/routing/features_road_graph.cpp +++ b/routing/features_road_graph.cpp @@ -69,9 +69,9 @@ bool FeaturesRoadGraph::CrossCountryVehicleModel::IsRoad(FeatureType const & f) return GetVehicleModel(f.GetID())->IsRoad(f); } -bool FeaturesRoadGraph::CrossCountryVehicleModel::IsTransitAllowed(FeatureType const & f) const +bool FeaturesRoadGraph::CrossCountryVehicleModel::IsPassThroughAllowed(FeatureType const & f) const { - return GetVehicleModel(f.GetID())->IsTransitAllowed(f); + return GetVehicleModel(f.GetID())->IsPassThroughAllowed(f); } VehicleModelInterface * FeaturesRoadGraph::CrossCountryVehicleModel::GetVehicleModel(FeatureID const & featureId) const diff --git a/routing/features_road_graph.hpp b/routing/features_road_graph.hpp index 424da7b36b..39148d116a 100644 --- a/routing/features_road_graph.hpp +++ b/routing/features_road_graph.hpp @@ -37,7 +37,7 @@ private: double GetOffroadSpeed() const override; bool IsOneWay(FeatureType const & f) const override; bool IsRoad(FeatureType const & f) const override; - bool IsTransitAllowed(FeatureType const & f) const override; + bool IsPassThroughAllowed(FeatureType const & f) const override; void Clear(); diff --git a/routing/geometry.cpp b/routing/geometry.cpp index d12fff0ff2..23a41ff4ca 100644 --- a/routing/geometry.cpp +++ b/routing/geometry.cpp @@ -114,7 +114,7 @@ void RoadGeometry::Load(VehicleModelInterface const & vehicleModel, FeatureType m_valid = vehicleModel.IsRoad(feature); m_isOneWay = vehicleModel.IsOneWay(feature); m_speed = vehicleModel.GetSpeed(feature); - m_isTransitAllowed = vehicleModel.IsTransitAllowed(feature); + m_isPassThroughAllowed = vehicleModel.IsPassThroughAllowed(feature); m_junctions.clear(); m_junctions.reserve(feature.GetPointsCount()); diff --git a/routing/geometry.hpp b/routing/geometry.hpp index d30cffa347..f49343677d 100644 --- a/routing/geometry.hpp +++ b/routing/geometry.hpp @@ -33,7 +33,7 @@ public: bool IsOneWay() const { return m_isOneWay; } // Kilometers per hour. double GetSpeed() const { return m_speed; } - bool IsTransitAllowed() const { return m_isTransitAllowed; } + bool IsPassThroughAllowed() const { return m_isPassThroughAllowed; } Junction const & GetJunction(uint32_t junctionId) const { @@ -57,14 +57,17 @@ public: return pointId == 0 || pointId + 1 == GetPointsCount(); } - void SetTransitAllowedForTests(bool transitAllowed) { m_isTransitAllowed = transitAllowed; } + void SetPassThroughAllowedForTests(bool passThroughAllowed) + { + m_isPassThroughAllowed = passThroughAllowed; + } private: buffer_vector m_junctions; double m_speed = 0.0; bool m_isOneWay = false; bool m_valid = false; - bool m_isTransitAllowed = false; + bool m_isPassThroughAllowed = false; }; class GeometryLoader diff --git a/routing/index_graph.cpp b/routing/index_graph.cpp index 9fad353c3e..a8b28bf852 100644 --- a/routing/index_graph.cpp +++ b/routing/index_graph.cpp @@ -113,14 +113,14 @@ RouteWeight IndexGraph::HeuristicCostEstimate(Segment const & from, Segment cons { return RouteWeight( m_estimator->CalcHeuristic(GetPoint(from, true /* front */), GetPoint(to, true /* front */)), - 0 /* nontransitCross */); + 0 /* nonPassThroughCross */); } RouteWeight IndexGraph::CalcSegmentWeight(Segment const & segment) { return RouteWeight( m_estimator->CalcSegmentWeight(segment, m_geometry.GetRoad(segment.GetFeatureId())), - 0 /* nontransitCross */); + 0 /* nonPassThroughCross */); } void IndexGraph::GetNeighboringEdges(Segment const & from, RoadPoint const & rp, bool isOutgoing, @@ -172,14 +172,14 @@ void IndexGraph::GetNeighboringEdge(Segment const & from, Segment const & to, bo RouteWeight IndexGraph::GetPenalties(Segment const & u, Segment const & v) { - bool const fromTransitAllowed = m_geometry.GetRoad(u.GetFeatureId()).IsTransitAllowed(); - bool const toTransitAllowed = m_geometry.GetRoad(v.GetFeatureId()).IsTransitAllowed(); + bool const fromPassThroughAllowed = m_geometry.GetRoad(u.GetFeatureId()).IsPassThroughAllowed(); + bool const toPassThroughAllowed = m_geometry.GetRoad(v.GetFeatureId()).IsPassThroughAllowed(); - uint32_t const transitPenalty = fromTransitAllowed == toTransitAllowed ? 0 : 1; + uint32_t const passThroughPenalty = fromPassThroughAllowed == toPassThroughAllowed ? 0 : 1; if (IsUTurn(u, v)) - return RouteWeight(m_estimator->GetUTurnPenalty(), transitPenalty); + return RouteWeight(m_estimator->GetUTurnPenalty(), passThroughPenalty); - return RouteWeight(0.0, transitPenalty); + return RouteWeight(0.0, passThroughPenalty); } } // namespace routing diff --git a/routing/index_graph_starter.cpp b/routing/index_graph_starter.cpp index 4fbef6f8df..576298d057 100644 --- a/routing/index_graph_starter.cpp +++ b/routing/index_graph_starter.cpp @@ -109,37 +109,37 @@ set IndexGraphStarter::GetMwms() const return mwms; } -bool IndexGraphStarter::DoesRouteCrossNontransit( +bool IndexGraphStarter::DoesRouteCrossNonPassThrough( RoutingResult const & result) const { - int nontransitCrossAllowed = 0; + int nonPassThroughCrossAllowed = 0; auto isRealOrPart = [this](Segment const & segment) { if (!IsFakeSegment(segment)) return true; Segment dummy; return m_fake.FindReal(segment, dummy); }; - auto isTransitAllowed = [this](Segment const & segment) { + auto isPassThroughAllowed = [this](Segment const & segment) { auto real = segment; bool const convertionResult = ConvertToReal(real); CHECK(convertionResult, ()); - return m_graph.IsTransitAllowed(real.GetMwmId(), real.GetFeatureId()); + return m_graph.IsPassThroughAllowed(real.GetMwmId(), real.GetFeatureId()); }; auto const firstRealOrPart = find_if(result.m_path.begin(), result.m_path.end(), isRealOrPart); - if (firstRealOrPart != result.m_path.end() && !isTransitAllowed(*firstRealOrPart)) - ++nontransitCrossAllowed; + if (firstRealOrPart != result.m_path.end() && !isPassThroughAllowed(*firstRealOrPart)) + ++nonPassThroughCrossAllowed; auto const lastRealOrPart = find_if(result.m_path.rbegin(), result.m_path.rend(), isRealOrPart); // If firstRealOrPart and lastRealOrPart point to the same segment increment - // nontransitCrossAllowed once + // nonPassThroughCrossAllowed once if (lastRealOrPart != result.m_path.rend() && &*lastRealOrPart != &*firstRealOrPart && - !isTransitAllowed(*lastRealOrPart)) + !isPassThroughAllowed(*lastRealOrPart)) { - ++nontransitCrossAllowed; + ++nonPassThroughCrossAllowed; } - return nontransitCrossAllowed < result.m_distance.GetNontransitCross(); + return nonPassThroughCrossAllowed < result.m_distance.GetNonPassThroughCross(); } void IndexGraphStarter::GetEdgesList(Segment const & segment, bool isOutgoing, diff --git a/routing/index_graph_starter.hpp b/routing/index_graph_starter.hpp index c4d0639752..e4cf456cf1 100644 --- a/routing/index_graph_starter.hpp +++ b/routing/index_graph_starter.hpp @@ -74,10 +74,10 @@ public: std::set GetMwms() const; - // Checks |result| meets nontransit crossing restrictions according to placement of - // |result.path| start and finish in transit/nontransit area and number of nontransit crosses - bool DoesRouteCrossNontransit( - RoutingResult const & result) const; + // Checks |result| meets non-pass-through crossing restrictions according to placement of + // |result.path| start and finish in pass through/non-pass-through area and number of + // non-pass-through crosses. + bool DoesRouteCrossNonPassThrough(RoutingResult const & result) const; void GetEdgesList(Segment const & segment, bool isOutgoing, std::vector & edges) const; diff --git a/routing/index_router.cpp b/routing/index_router.cpp index 65527580b5..47a50d7c7a 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -566,7 +566,7 @@ IRouter::ResultCode IndexRouter::CalculateSubroute(Checkpoints const & checkpoin if (result != IRouter::NoError) return result; - if (starter.DoesRouteCrossNontransit(routingResult)) + if (starter.DoesRouteCrossNonPassThrough(routingResult)) return IRouter::RouteNotFound; IRouter::ResultCode const leapsResult = @@ -637,9 +637,10 @@ IRouter::ResultCode IndexRouter::AdjustRoute(Checkpoints const & checkpoints, AStarAlgorithm algorithm; RoutingResult result; - auto resultCode = ConvertResult(algorithm.AdjustRoute( - starter, starter.GetStartSegment(), prevEdges, - RouteWeight(kAdjustLimitSec, 0 /* nontransitCross */), result, delegate, onVisitJunction)); + auto resultCode = ConvertResult( + algorithm.AdjustRoute(starter, starter.GetStartSegment(), prevEdges, + RouteWeight(kAdjustLimitSec, 0 /* nonPassThroughCross */), result, + delegate, onVisitJunction)); if (resultCode != IRouter::NoError) return resultCode; diff --git a/routing/road_access.hpp b/routing/road_access.hpp index 3d1af10d8f..4c6e3911fc 100644 --- a/routing/road_access.hpp +++ b/routing/road_access.hpp @@ -28,7 +28,7 @@ public: // Moving through the road requires a special permission. Private, - // No transit through the road is allowed; however, it can + // No pass through the road is allowed; however, it can // be used if it is close enough to the destination point // of the route. Destination, diff --git a/routing/route_weight.cpp b/routing/route_weight.cpp index a8645f457d..a70f0ef0b6 100644 --- a/routing/route_weight.cpp +++ b/routing/route_weight.cpp @@ -8,19 +8,19 @@ namespace routing { double RouteWeight::ToCrossMwmWeight() const { - if (m_nontransitCross > 0) + if (m_nonPassThroughCross > 0) return CrossMwmConnector::kNoRoute; return GetWeight(); } ostream & operator<<(ostream & os, RouteWeight const & routeWeight) { - os << "(" << routeWeight.GetNontransitCross() << ", " << routeWeight.GetWeight() << ")"; + os << "(" << routeWeight.GetNonPassThroughCross() << ", " << routeWeight.GetWeight() << ")"; return os; } RouteWeight operator*(double lhs, RouteWeight const & rhs) { - return RouteWeight(lhs * rhs.GetWeight(), rhs.GetNontransitCross()); + return RouteWeight(lhs * rhs.GetWeight(), rhs.GetNonPassThroughCross()); } } // namespace routing diff --git a/routing/route_weight.hpp b/routing/route_weight.hpp index e6d7dfa8d2..f4c823d7de 100644 --- a/routing/route_weight.hpp +++ b/routing/route_weight.hpp @@ -12,24 +12,24 @@ class RouteWeight final public: RouteWeight() = default; - constexpr RouteWeight(double weight, int nontransitCross) - : m_weight(weight), m_nontransitCross(nontransitCross) + constexpr RouteWeight(double weight, int nonPassThroughCross) + : m_weight(weight), m_nonPassThroughCross(nonPassThroughCross) { } static RouteWeight FromCrossMwmWeight(double weight) { - return RouteWeight(weight, 0 /* nontransitCross */); + return RouteWeight(weight, 0 /* nonPassThroughCross */); } double ToCrossMwmWeight() const; double GetWeight() const { return m_weight; } - int GetNontransitCross() const { return m_nontransitCross; } + int GetNonPassThroughCross() const { return m_nonPassThroughCross; } bool operator<(RouteWeight const & rhs) const { - if (m_nontransitCross != rhs.m_nontransitCross) - return m_nontransitCross < rhs.m_nontransitCross; + if (m_nonPassThroughCross != rhs.m_nonPassThroughCross) + return m_nonPassThroughCross < rhs.m_nonPassThroughCross; return m_weight < rhs.m_weight; } @@ -43,28 +43,28 @@ public: RouteWeight operator+(RouteWeight const & rhs) const { - return RouteWeight(m_weight + rhs.m_weight, m_nontransitCross + rhs.m_nontransitCross); + return RouteWeight(m_weight + rhs.m_weight, m_nonPassThroughCross + rhs.m_nonPassThroughCross); } RouteWeight operator-(RouteWeight const & rhs) const { - return RouteWeight(m_weight - rhs.m_weight, m_nontransitCross - rhs.m_nontransitCross); + return RouteWeight(m_weight - rhs.m_weight, m_nonPassThroughCross - rhs.m_nonPassThroughCross); } RouteWeight & operator+=(RouteWeight const & rhs) { m_weight += rhs.m_weight; - m_nontransitCross += rhs.m_nontransitCross; + m_nonPassThroughCross += rhs.m_nonPassThroughCross; return *this; } - RouteWeight operator-() const { return RouteWeight(-m_weight, -m_nontransitCross); } + RouteWeight operator-() const { return RouteWeight(-m_weight, -m_nonPassThroughCross); } private: // Regular weight (seconds). double m_weight = 0.0; - // Number of transit/nontransit area border cross. - int m_nontransitCross = 0; + // Number of pass-through/non-pass-through area border cross. + int m_nonPassThroughCross = 0; }; std::ostream & operator<<(std::ostream & os, RouteWeight const & routeWeight); @@ -75,19 +75,19 @@ template <> constexpr RouteWeight GetAStarWeightMax() { return RouteWeight(std::numeric_limits::max() /* weight */, - std::numeric_limits::max() /* nontransitCross */); + std::numeric_limits::max() /* nonPassThroughCross */); } template <> constexpr RouteWeight GetAStarWeightZero() { - return RouteWeight(0.0 /* weight */, 0 /* nontransitCross */); + return RouteWeight(0.0 /* weight */, 0 /* nonPassThroughCross */); } template <> constexpr RouteWeight GetAStarWeightEpsilon() { - return RouteWeight(GetAStarWeightEpsilon(), 0 /* nontransitCross */); + return RouteWeight(GetAStarWeightEpsilon(), 0 /* nonPassThroughCross */); } } // namespace routing diff --git a/routing/routing_tests/index_graph_tools.cpp b/routing/routing_tests/index_graph_tools.cpp index f8c32f5de2..3a2984040e 100644 --- a/routing/routing_tests/index_graph_tools.cpp +++ b/routing/routing_tests/index_graph_tools.cpp @@ -55,14 +55,14 @@ void TestGeometryLoader::AddRoad(uint32_t featureId, bool oneWay, float speed, auto it = m_roads.find(featureId); CHECK(it == m_roads.end(), ("Already contains feature", featureId)); m_roads[featureId] = RoadGeometry(oneWay, speed, points); - m_roads[featureId].SetTransitAllowedForTests(true); + m_roads[featureId].SetPassThroughAllowedForTests(true); } -void TestGeometryLoader::SetTransitAllowed(uint32_t featureId, bool transitAllowed) +void TestGeometryLoader::SetPassThroughAllowed(uint32_t featureId, bool passThroughAllowed) { auto it = m_roads.find(featureId); CHECK(it != m_roads.end(), ("No feature", featureId)); - m_roads[featureId].SetTransitAllowedForTests(transitAllowed); + m_roads[featureId].SetPassThroughAllowedForTests(passThroughAllowed); } // ZeroGeometryLoader ------------------------------------------------------------------------------ @@ -355,7 +355,7 @@ AStarAlgorithm::Result CalculateRoute(IndexGraphStarter & sta starter, starter.GetStartSegment(), starter.GetFinishSegment(), routingResult, {} /* cancellable */, {} /* onVisitedVertexCallback */); - if (starter.DoesRouteCrossNontransit(routingResult)) + if (starter.DoesRouteCrossNonPassThrough(routingResult)) resultCode = AStarAlgorithm::Result::NoPath; timeSec = routingResult.m_distance.GetWeight(); diff --git a/routing/routing_tests/index_graph_tools.hpp b/routing/routing_tests/index_graph_tools.hpp index 941887d6ec..58a7e24f6c 100644 --- a/routing/routing_tests/index_graph_tools.hpp +++ b/routing/routing_tests/index_graph_tools.hpp @@ -66,7 +66,7 @@ public: void AddRoad(uint32_t featureId, bool oneWay, float speed, routing::RoadGeometry::Points const & points); - void SetTransitAllowed(uint32_t featureId, bool transitAllowed); + void SetPassThroughAllowed(uint32_t featureId, bool passThroughAllowed); private: unordered_map m_roads; diff --git a/routing/routing_tests/restriction_test.cpp b/routing/routing_tests/restriction_test.cpp index 3a25c57f1d..bc7fbf47cc 100644 --- a/routing/routing_tests/restriction_test.cpp +++ b/routing/routing_tests/restriction_test.cpp @@ -823,23 +823,24 @@ UNIT_CLASS_TEST(RestrictionTest, FGraph_RestrictionF0F2Only) // | | // 0 Start *---F0---*---F1---*---F2---* Finish // 0 1 2 3 -unique_ptr BuildNontransitGraph(bool transitStart, bool transitShortWay, - bool transitLongWay) +unique_ptr BuildNonPassThroughGraph(bool passThroughStart, + bool passThroughShortWay, + bool passThroughLongWay) { unique_ptr loader = make_unique(); loader->AddRoad(0 /* feature id */, false /* one way */, 1.0 /* speed */, RoadGeometry::Points({{0.0, 0.0}, {1.0, 0.0}})); - loader->SetTransitAllowed(0 /* feature id */, transitStart); + loader->SetPassThroughAllowed(0 /* feature id */, passThroughStart); loader->AddRoad(1 /* feature id */, false /* one way */, 1.0 /* speed */, RoadGeometry::Points({{1.0, 0.0}, {2.0, 0.0}})); - loader->SetTransitAllowed(1 /* feature id */, transitShortWay); + loader->SetPassThroughAllowed(1 /* feature id */, passThroughShortWay); loader->AddRoad(2 /* feature id */, false /* one way */, 1.0 /* speed */, RoadGeometry::Points({{2.0, 0.0}, {3.0, 0.0}})); loader->AddRoad(3 /* feature id */, false /* one way */, 1.0 /* speed */, RoadGeometry::Points({{1.0, 0.0}, {1.0, 1.0}})); loader->AddRoad(4 /* feature id */, false /* one way */, 1.0 /* speed */, RoadGeometry::Points({{1.0, 1.0}, {2.0, 1.0}})); - loader->SetTransitAllowed(4 /* feature id */, transitLongWay); + loader->SetPassThroughAllowed(4 /* feature id */, passThroughLongWay); loader->AddRoad(5 /* feature id */, false /* one way */, 1.0 /* speed */, RoadGeometry::Points({{2.0, 1.0}, {2.0, 0.0}})); @@ -857,10 +858,10 @@ unique_ptr BuildNontransitGraph(bool transitStart, bool return BuildWorldGraph(move(loader), estimator, joints); } -UNIT_CLASS_TEST(RestrictionTest, NontransitStart) +UNIT_CLASS_TEST(RestrictionTest, NonPassThroughStart) { - Init(BuildNontransitGraph(false /* transitStart */, true /* transitShortWay */, - true /* transitLongWay */)); + Init(BuildNonPassThroughGraph(false /* passThroughStart */, true /* passThroughShortWay */, + true /* passThroughLongWay */)); vector const expectedGeom = {{0 /* x */, 0 /* y */}, {1, 0}, {2, 0}, {3, 0}}; SetStarter(MakeFakeEnding(0 /* featureId */, 0 /* segmentIdx */, m2::PointD(0, 0), *m_graph), @@ -868,10 +869,10 @@ UNIT_CLASS_TEST(RestrictionTest, NontransitStart) TestRouteGeometry(*m_starter, AStarAlgorithm::Result::OK, expectedGeom); } -UNIT_CLASS_TEST(RestrictionTest, NontransitShortWay) +UNIT_CLASS_TEST(RestrictionTest, NonPassThroughShortWay) { - Init(BuildNontransitGraph(true /* transitStart */, false /* transitShortWay */, - true /* transitLongWay */)); + Init(BuildNonPassThroughGraph(true /* passThroughStart */, false /* passThroughShortWay */, + true /* passThroughLongWay */)); vector const expectedGeom = { {0 /* x */, 0 /* y */}, {1, 0}, {1, 1}, {2, 1}, {2, 0}, {3, 0}}; @@ -880,10 +881,10 @@ UNIT_CLASS_TEST(RestrictionTest, NontransitShortWay) TestRouteGeometry(*m_starter, AStarAlgorithm::Result::OK, expectedGeom); } -UNIT_CLASS_TEST(RestrictionTest, NontransitWay) +UNIT_CLASS_TEST(RestrictionTest, NonPassThroughWay) { - Init(BuildNontransitGraph(true /* transitStart */, false /* transitShortWay */, - false /* transitLongWay */)); + Init(BuildNonPassThroughGraph(true /* passThroughStart */, false /* passThroughShortWay */, + false /* passThroughLongWay */)); SetStarter(MakeFakeEnding(0 /* featureId */, 0 /* segmentIdx */, m2::PointD(0, 0), *m_graph), MakeFakeEnding(2, 0, m2::PointD(3, 0), *m_graph)); @@ -892,9 +893,9 @@ UNIT_CLASS_TEST(RestrictionTest, NontransitWay) UNIT_CLASS_TEST(RestrictionTest, NontransiStartAndShortWay) { - Init(BuildNontransitGraph(false /* transitStart */, false /* transitShortWay */, - true /* transitLongWay */)); - // We can get F1 because F0 is in the same nontransit area/ + Init(BuildNonPassThroughGraph(false /* passThroughStart */, false /* passThroughShortWay */, + true /* passThroughLongWay */)); + // We can get F1 because F0 is in the same non-pass-through area/ vector const expectedGeom = {{0 /* x */, 0 /* y */}, {1, 0}, {2, 0}, {3, 0}}; SetStarter(MakeFakeEnding(0 /* featureId */, 0 /* segmentIdx */, m2::PointD(0, 0), *m_graph), diff --git a/routing/single_vehicle_world_graph.cpp b/routing/single_vehicle_world_graph.cpp index 6b05ce05a9..7612fedbd0 100644 --- a/routing/single_vehicle_world_graph.cpp +++ b/routing/single_vehicle_world_graph.cpp @@ -35,7 +35,7 @@ void SingleVehicleWorldGraph::GetEdgeList(Segment const & segment, bool isOutgoi edges.emplace_back( transition, RouteWeight(m_estimator->CalcLeapWeight(segmentPoint, GetPoint(transition, isOutgoing)), - 0 /* nontransitCross */)); + 0 /* nonPassThroughCross */)); }); return; } @@ -73,9 +73,9 @@ bool SingleVehicleWorldGraph::IsOneWay(NumMwmId mwmId, uint32_t featureId) return GetRoadGeometry(mwmId, featureId).IsOneWay(); } -bool SingleVehicleWorldGraph::IsTransitAllowed(NumMwmId mwmId, uint32_t featureId) +bool SingleVehicleWorldGraph::IsPassThroughAllowed(NumMwmId mwmId, uint32_t featureId) { - return GetRoadGeometry(mwmId, featureId).IsTransitAllowed(); + return GetRoadGeometry(mwmId, featureId).IsPassThroughAllowed(); } void SingleVehicleWorldGraph::GetOutgoingEdgesList(Segment const & segment, @@ -100,20 +100,20 @@ RouteWeight SingleVehicleWorldGraph::HeuristicCostEstimate(Segment const & from, RouteWeight SingleVehicleWorldGraph::HeuristicCostEstimate(m2::PointD const & from, m2::PointD const & to) { - return RouteWeight(m_estimator->CalcHeuristic(from, to), 0 /* nontransitCross */); + return RouteWeight(m_estimator->CalcHeuristic(from, to), 0 /* nonPassThroughCross */); } RouteWeight SingleVehicleWorldGraph::CalcSegmentWeight(Segment const & segment) { return RouteWeight(m_estimator->CalcSegmentWeight( segment, GetRoadGeometry(segment.GetMwmId(), segment.GetFeatureId())), - 0 /* nontransitCross */); + 0 /* nonPassThroughCross */); } RouteWeight SingleVehicleWorldGraph::CalcOffroadWeight(m2::PointD const & from, m2::PointD const & to) const { - return RouteWeight(m_estimator->CalcOffroadWeight(from, to), 0 /* nontransitCross */); + return RouteWeight(m_estimator->CalcOffroadWeight(from, to), 0 /* nonPassThroughCross */); } bool SingleVehicleWorldGraph::LeapIsAllowed(NumMwmId mwmId) const @@ -141,7 +141,7 @@ void SingleVehicleWorldGraph::GetTwins(Segment const & segment, bool isOutgoing, // in different mwms. But if we have mwms with different versions and feature // was moved in one of them we can have nonzero weight here. double const weight = m_estimator->CalcHeuristic(from, to); - edges.emplace_back(twin, RouteWeight(weight, 0 /* nontransitCross */)); + edges.emplace_back(twin, RouteWeight(weight, 0 /* nonPassThroughCross */)); } } } // namespace routing diff --git a/routing/single_vehicle_world_graph.hpp b/routing/single_vehicle_world_graph.hpp index 718bcefb6b..ff66ba9bc3 100644 --- a/routing/single_vehicle_world_graph.hpp +++ b/routing/single_vehicle_world_graph.hpp @@ -32,7 +32,7 @@ public: Junction const & GetJunction(Segment const & segment, bool front) override; m2::PointD const & GetPoint(Segment const & segment, bool front) override; bool IsOneWay(NumMwmId mwmId, uint32_t featureId) override; - bool IsTransitAllowed(NumMwmId mwmId, uint32_t featureId) override; + bool IsPassThroughAllowed(NumMwmId mwmId, uint32_t featureId) override; void ClearCachedGraphs() override { m_loader->Clear(); } void SetMode(Mode mode) override { m_mode = mode; } Mode GetMode() const override { return m_mode; } diff --git a/routing/transit_world_graph.cpp b/routing/transit_world_graph.cpp index bc9f40dcbe..8d12e6d36b 100644 --- a/routing/transit_world_graph.cpp +++ b/routing/transit_world_graph.cpp @@ -85,11 +85,11 @@ bool TransitWorldGraph::IsOneWay(NumMwmId mwmId, uint32_t featureId) return GetRealRoadGeometry(mwmId, featureId).IsOneWay(); } -bool TransitWorldGraph::IsTransitAllowed(NumMwmId mwmId, uint32_t featureId) +bool TransitWorldGraph::IsPassThroughAllowed(NumMwmId mwmId, uint32_t featureId) { if (TransitGraph::IsTransitFeature(featureId)) return true; - return GetRealRoadGeometry(mwmId, featureId).IsTransitAllowed(); + return GetRealRoadGeometry(mwmId, featureId).IsPassThroughAllowed(); } void TransitWorldGraph::ClearCachedGraphs() diff --git a/routing/transit_world_graph.hpp b/routing/transit_world_graph.hpp index d9f48dae31..dd87255780 100644 --- a/routing/transit_world_graph.hpp +++ b/routing/transit_world_graph.hpp @@ -36,8 +36,8 @@ public: m2::PointD const & GetPoint(Segment const & segment, bool front) override; // All transit features are oneway. bool IsOneWay(NumMwmId mwmId, uint32_t featureId) override; - // All transit features are allowed for through pass. - bool IsTransitAllowed(NumMwmId mwmId, uint32_t featureId) override; + // All transit features are allowed for through passage. + bool IsPassThroughAllowed(NumMwmId mwmId, uint32_t featureId) override; void ClearCachedGraphs() override; void SetMode(Mode mode) override { m_mode = mode; } Mode GetMode() const override { return m_mode; } diff --git a/routing/world_graph.hpp b/routing/world_graph.hpp index 1dc149b08a..2535de541f 100644 --- a/routing/world_graph.hpp +++ b/routing/world_graph.hpp @@ -50,10 +50,8 @@ public: virtual m2::PointD const & GetPoint(Segment const & segment, bool front) = 0; virtual bool IsOneWay(NumMwmId mwmId, uint32_t featureId) = 0; - // Checks feature is allowed for through pass. - // TODO (t.yan) it's better to use "transit" only for public transport. We should rename - // IsTransitAllowed to something like IsThroughPassAllowed everywhere. - virtual bool IsTransitAllowed(NumMwmId mwmId, uint32_t featureId) = 0; + // Checks feature is allowed for through passage. + virtual bool IsPassThroughAllowed(NumMwmId mwmId, uint32_t featureId) = 0; // Clear memory used by loaded graphs. virtual void ClearCachedGraphs() = 0; diff --git a/routing_common/bicycle_model.cpp b/routing_common/bicycle_model.cpp index 4e6067228e..fa98fb15a3 100644 --- a/routing_common/bicycle_model.cpp +++ b/routing_common/bicycle_model.cpp @@ -54,7 +54,7 @@ double constexpr kSpeedOffroadKMpH = 3.0; // Default VehicleModel::InitListT const g_bicycleLimitsDefault = { - { {"highway", "trunk"}, kSpeedTrunkKMpH, true /* transitAllowed */ }, + { {"highway", "trunk"}, kSpeedTrunkKMpH, true /* passThroughAllowed */ }, { {"highway", "trunk_link"}, kSpeedTrunkLinkKMpH, true }, { {"highway", "primary"}, kSpeedPrimaryKMpH, true }, { {"highway", "primary_link"}, kSpeedPrimaryLinkKMpH, true }, @@ -327,7 +327,7 @@ VehicleModel::InitListT const g_bicycleLimitsRomania = g_bicycleLimitsNoTrunk; VehicleModel::InitListT const g_bicycleLimitsRussia = { // Footway and pedestrian are allowed - // No transit for service and living_street + // No pass through service and living_street { {"highway", "trunk"}, kSpeedTrunkKMpH, true }, { {"highway", "trunk_link"}, kSpeedTrunkLinkKMpH, true }, { {"highway", "primary"}, kSpeedPrimaryKMpH, true }, @@ -367,7 +367,7 @@ VehicleModel::InitListT const g_bicycleLimitsUkraine = { // No trunk // Footway and perestrian are allowed - // No transit for living_street and service + // No pass through living_street and service { {"highway", "primary"}, kSpeedPrimaryKMpH, true }, { {"highway", "primary_link"}, kSpeedPrimaryLinkKMpH, true }, { {"highway", "secondary"}, kSpeedSecondaryKMpH, true }, diff --git a/routing_common/car_model.cpp b/routing_common/car_model.cpp index 65e529e073..889c34fed7 100644 --- a/routing_common/car_model.cpp +++ b/routing_common/car_model.cpp @@ -42,7 +42,7 @@ double constexpr kSpeedOffroadKMpH = 10.0; VehicleModel::InitListT const g_carLimitsDefault = { - {{"highway", "motorway"}, kSpeedMotorwayKMpH, true /* isTransitAllowed */ }, + {{"highway", "motorway"}, kSpeedMotorwayKMpH, true /* passThroughAllowed */ }, {{"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH, true}, {{"highway", "trunk"}, kSpeedTrunkKMpH, true}, {{"highway", "trunk_link"}, kSpeedTrunkLinkKMpH, true}, @@ -66,7 +66,7 @@ VehicleModel::InitListT const g_carLimitsDefault = //{ {"highway", "construction"}, 40 }, }; -VehicleModel::InitListT const g_carLimitsNoLivingStreetTransit = +VehicleModel::InitListT const g_carLimitsNoPassThroughLivingStreet = { {{"highway", "motorway"}, kSpeedMotorwayKMpH, true}, {{"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH, true}, @@ -86,7 +86,7 @@ VehicleModel::InitListT const g_carLimitsNoLivingStreetTransit = {{"highway", "track"}, kSpeedTrackKMpH, true}, }; -VehicleModel::InitListT const g_carLimitsNoLivingStreetAndServiceTransit = +VehicleModel::InitListT const g_carLimitsNoPassThroughLivingStreetAndService = { {{"highway", "motorway"}, kSpeedMotorwayKMpH, true}, {{"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH, true}, @@ -108,9 +108,9 @@ VehicleModel::InitListT const g_carLimitsNoLivingStreetAndServiceTransit = VehicleModel::InitListT const g_carLimitsAustralia = g_carLimitsDefault; -VehicleModel::InitListT const g_carLimitsAustria = g_carLimitsNoLivingStreetTransit; +VehicleModel::InitListT const g_carLimitsAustria = g_carLimitsNoPassThroughLivingStreet; -VehicleModel::InitListT const g_carLimitsBelarus = g_carLimitsNoLivingStreetTransit; +VehicleModel::InitListT const g_carLimitsBelarus = g_carLimitsNoPassThroughLivingStreet; VehicleModel::InitListT const g_carLimitsBelgium = g_carLimitsDefault; @@ -142,7 +142,7 @@ VehicleModel::InitListT const g_carLimitsFinland = g_carLimitsDefault; VehicleModel::InitListT const g_carLimitsGermany = { - // No transit for track + // No pass through track {{"highway", "motorway"}, kSpeedMotorwayKMpH, true}, {{"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH, true}, {{"highway", "trunk"}, kSpeedTrunkKMpH, true}, @@ -161,7 +161,7 @@ VehicleModel::InitListT const g_carLimitsGermany = {{"highway", "track"}, kSpeedTrackKMpH, false}, }; -VehicleModel::InitListT const g_carLimitsHungary = g_carLimitsNoLivingStreetTransit; +VehicleModel::InitListT const g_carLimitsHungary = g_carLimitsNoPassThroughLivingStreet; VehicleModel::InitListT const g_carLimitsIceland = g_carLimitsDefault; @@ -173,11 +173,11 @@ VehicleModel::InitListT const g_carLimitsOman = g_carLimitsDefault; VehicleModel::InitListT const g_carLimitsPoland = g_carLimitsDefault; -VehicleModel::InitListT const g_carLimitsRomania = g_carLimitsNoLivingStreetTransit; +VehicleModel::InitListT const g_carLimitsRomania = g_carLimitsNoPassThroughLivingStreet; -VehicleModel::InitListT const g_carLimitsRussia = g_carLimitsNoLivingStreetAndServiceTransit; +VehicleModel::InitListT const g_carLimitsRussia = g_carLimitsNoPassThroughLivingStreetAndService; -VehicleModel::InitListT const g_carLimitsSlovakia = g_carLimitsNoLivingStreetTransit; +VehicleModel::InitListT const g_carLimitsSlovakia = g_carLimitsNoPassThroughLivingStreet; VehicleModel::InitListT const g_carLimitsSpain = g_carLimitsDefault; @@ -185,7 +185,7 @@ VehicleModel::InitListT const g_carLimitsSwitzerland = g_carLimitsDefault; VehicleModel::InitListT const g_carLimitsTurkey = g_carLimitsDefault; -VehicleModel::InitListT const g_carLimitsUkraine = g_carLimitsNoLivingStreetAndServiceTransit; +VehicleModel::InitListT const g_carLimitsUkraine = g_carLimitsNoPassThroughLivingStreetAndService; VehicleModel::InitListT const g_carLimitsUK = g_carLimitsDefault; diff --git a/routing_common/pedestrian_model.cpp b/routing_common/pedestrian_model.cpp index 7352b93ca3..e0c2a4ed5e 100644 --- a/routing_common/pedestrian_model.cpp +++ b/routing_common/pedestrian_model.cpp @@ -54,7 +54,7 @@ double constexpr kSpeedOffroadKMpH = 3.0; // Default VehicleModel::InitListT const g_pedestrianLimitsDefault = { - { {"highway", "trunk"}, kSpeedTrunkKMpH, true /* transitAllowed */ }, + { {"highway", "trunk"}, kSpeedTrunkKMpH, true /* passThroughAllowed */ }, { {"highway", "trunk_link"}, kSpeedTrunkLinkKMpH, true }, { {"highway", "primary"}, kSpeedPrimaryKMpH, true }, { {"highway", "primary_link"}, kSpeedPrimaryLinkKMpH, true }, diff --git a/routing_common/routing_common_tests/vehicle_model_test.cpp b/routing_common/routing_common_tests/vehicle_model_test.cpp index ba448fe718..4f241d28b4 100644 --- a/routing_common/routing_common_tests/vehicle_model_test.cpp +++ b/routing_common/routing_common_tests/vehicle_model_test.cpp @@ -27,7 +27,7 @@ public: class TestVehicleModel : public routing::VehicleModel { friend void CheckOneWay(initializer_list const & types, bool expectedValue); - friend void CheckTransitAllowed(initializer_list const & types, bool expectedValue); + friend void CheckPassThroughAllowed(initializer_list const & types, bool expectedValue); friend void CheckSpeed(initializer_list const & types, double expectedSpeed); public: @@ -69,14 +69,14 @@ void CheckOneWay(initializer_list const & types, bool expectedValue) TEST_EQUAL(vehicleModel.HasOneWayType(h), expectedValue, ()); } -void CheckTransitAllowed(initializer_list const & types, bool expectedValue) +void CheckPassThroughAllowed(initializer_list const & types, bool expectedValue) { TestVehicleModel vehicleModel; feature::TypesHolder h; for (uint32_t t : types) h.Add(t); - TEST_EQUAL(vehicleModel.HasTransitType(h), expectedValue, ()); + TEST_EQUAL(vehicleModel.HasPassThroughType(h), expectedValue, ()); } } // namespace @@ -134,9 +134,9 @@ UNIT_CLASS_TEST(VehicleModelTest, VehicleModel_DifferentSpeeds) CheckOneWay({typePrimary, typeOneway, typeSecondary}, true); } -UNIT_CLASS_TEST(VehicleModelTest, VehicleModel_TransitAllowed) +UNIT_CLASS_TEST(VehicleModelTest, VehicleModel_PassThroughAllowed) { - CheckTransitAllowed({GetType("highway", "secondary")}, true); - CheckTransitAllowed({GetType("highway", "primary")}, true); - CheckTransitAllowed({GetType("highway", "service")}, false); + CheckPassThroughAllowed({GetType("highway", "secondary")}, true); + CheckPassThroughAllowed({GetType("highway", "primary")}, true); + CheckPassThroughAllowed({GetType("highway", "service")}, false); } diff --git a/routing_common/vehicle_model.cpp b/routing_common/vehicle_model.cpp index d3eda7041d..00c6645880 100644 --- a/routing_common/vehicle_model.cpp +++ b/routing_common/vehicle_model.cpp @@ -18,8 +18,8 @@ VehicleModel::AdditionalRoadType::AdditionalRoadType(Classificator const & c, { } -VehicleModel::RoadLimits::RoadLimits(double speedKMpH, bool isTransitAllowed) - : m_speedKMpH(speedKMpH), m_isTransitAllowed(isTransitAllowed) +VehicleModel::RoadLimits::RoadLimits(double speedKMpH, bool isPassThroughAllowed) + : m_speedKMpH(speedKMpH), m_isPassThroughAllowed(isPassThroughAllowed) { CHECK_GREATER(m_speedKMpH, 0.0, ()); } @@ -32,7 +32,7 @@ VehicleModel::VehicleModel(Classificator const & c, InitListT const & featureTyp { m_maxSpeedKMpH = max(m_maxSpeedKMpH, v.m_speedKMpH); m_types.emplace(c.GetTypeByPath(vector(v.m_types, v.m_types + 2)), - RoadLimits(v.m_speedKMpH, v.m_isTransitAllowed)); + RoadLimits(v.m_speedKMpH, v.m_isPassThroughAllowed)); } } @@ -111,19 +111,19 @@ bool VehicleModel::IsRoad(FeatureType const & f) const return HasRoadType(types); } -bool VehicleModel::IsTransitAllowed(FeatureType const & f) const +bool VehicleModel::IsPassThroughAllowed(FeatureType const & f) const { feature::TypesHolder const types(f); - return HasTransitType(types); + return HasPassThroughType(types); } -bool VehicleModel::HasTransitType(feature::TypesHolder const & types) const +bool VehicleModel::HasPassThroughType(feature::TypesHolder const & types) const { for (uint32_t t : types) { uint32_t const type = ftypes::BaseChecker::PrepareToMatch(t, 2); auto it = m_types.find(type); - if (it != m_types.end() && it->second.IsTransitAllowed()) + if (it != m_types.end() && it->second.IsPassThroughAllowed()) return true; } diff --git a/routing_common/vehicle_model.hpp b/routing_common/vehicle_model.hpp index 79206e5a99..ece3f0985b 100644 --- a/routing_common/vehicle_model.hpp +++ b/routing_common/vehicle_model.hpp @@ -43,8 +43,11 @@ public: /// @returns true iff feature |f| can be used for routing with corresponding vehicle model. virtual bool IsRoad(FeatureType const & f) const = 0; - /// @returns true iff feature |f| can be used for transit with corresponding vehicle model. - virtual bool IsTransitAllowed(FeatureType const & f) const = 0; + /// @returns true iff feature |f| can be used for through passage with corresponding vehicle model. + /// e.g. in Russia roads tagged "highway = service" are not allowed for through passage; + /// however, road with this tag can be be used if it is close enough to the start or destination + /// point of the route. + virtual bool IsPassThroughAllowed(FeatureType const & f) const = 0; }; class VehicleModelFactoryInterface @@ -65,9 +68,9 @@ class VehicleModel : public VehicleModelInterface public: struct FeatureTypeLimits final { - char const * m_types[2]; /// 2-arity road type - double m_speedKMpH; /// max allowed speed on this road type - bool m_isTransitAllowed; /// transit allowed for this road type + char const * m_types[2]; /// 2-arity road type + double m_speedKMpH; /// max allowed speed on this road type + bool m_isPassThroughAllowed; /// pass through this road type is allowed }; struct AdditionalRoadTags final @@ -92,7 +95,7 @@ public: double GetMaxSpeed() const override { return m_maxSpeedKMpH; } bool IsOneWay(FeatureType const & f) const override; bool IsRoad(FeatureType const & f) const override; - bool IsTransitAllowed(FeatureType const & f) const override; + bool IsPassThroughAllowed(FeatureType const & f) const override; public: /// @returns true if |m_types| or |m_addRoadTypes| contains |type| and false otherwise. @@ -131,7 +134,7 @@ protected: /// may be considered as features with forward geometry. bool HasOneWayType(feature::TypesHolder const & types) const; - bool HasTransitType(feature::TypesHolder const & types) const; + bool HasPassThroughType(feature::TypesHolder const & types) const; double GetMinTypeSpeed(feature::TypesHolder const & types) const; @@ -151,18 +154,19 @@ private: { public: RoadLimits() = delete; - RoadLimits(double speedKMpH, bool isTransitAllowed); + RoadLimits(double speedKMpH, bool isPassThroughAllowed); double GetSpeedKMpH() const { return m_speedKMpH; }; - bool IsTransitAllowed() const { return m_isTransitAllowed; }; + bool IsPassThroughAllowed() const { return m_isPassThroughAllowed; }; bool operator==(RoadLimits const & rhs) const { - return (m_speedKMpH == rhs.m_speedKMpH) && (m_isTransitAllowed == rhs.m_isTransitAllowed); + return (m_speedKMpH == rhs.m_speedKMpH) && + (m_isPassThroughAllowed == rhs.m_isPassThroughAllowed); } private: double const m_speedKMpH; - bool const m_isTransitAllowed; + bool const m_isPassThroughAllowed; }; std::vector::const_iterator FindRoadType(uint32_t type) const;