diff options
Diffstat (limited to 'routing')
-rw-r--r-- | routing/bicycle_directions.cpp | 18 | ||||
-rw-r--r-- | routing/bicycle_directions.hpp | 4 | ||||
-rw-r--r-- | routing/directions_engine.hpp | 2 | ||||
-rw-r--r-- | routing/loaded_path_segment.hpp | 3 | ||||
-rw-r--r-- | routing/osrm_path_segment_factory.cpp | 5 | ||||
-rw-r--r-- | routing/osrm_router.cpp | 26 | ||||
-rw-r--r-- | routing/pedestrian_directions.cpp | 12 | ||||
-rw-r--r-- | routing/pedestrian_directions.hpp | 2 | ||||
-rw-r--r-- | routing/road_graph.hpp | 14 | ||||
-rw-r--r-- | routing/road_graph_router.cpp | 13 | ||||
-rw-r--r-- | routing/routing_result_graph.hpp | 5 | ||||
-rw-r--r-- | routing/routing_tests/turns_generator_test.cpp | 28 | ||||
-rw-r--r-- | routing/turns_generator.cpp | 68 | ||||
-rw-r--r-- | routing/turns_generator.hpp | 4 |
14 files changed, 114 insertions, 90 deletions
diff --git a/routing/bicycle_directions.cpp b/routing/bicycle_directions.cpp index 3025e925a1..965bbe5173 100644 --- a/routing/bicycle_directions.cpp +++ b/routing/bicycle_directions.cpp @@ -56,16 +56,16 @@ public: double GetPathLength() const override { return m_routeLength; } - m2::PointD const & GetStartPoint() const override + Junction const & GetStartPoint() const override { CHECK(!m_routeEdges.empty(), ()); - return m_routeEdges.front().GetStartJunction().GetPoint(); + return m_routeEdges.front().GetStartJunction(); } - m2::PointD const & GetEndPoint() const override + Junction const & GetEndPoint() const override { CHECK(!m_routeEdges.empty(), ()); - return m_routeEdges.back().GetEndJunction().GetPoint(); + return m_routeEdges.back().GetEndJunction(); } private: @@ -82,7 +82,7 @@ BicycleDirectionsEngine::BicycleDirectionsEngine(Index const & index) : m_index( void BicycleDirectionsEngine::Generate(IRoadGraph const & graph, vector<Junction> const & path, Route::TTimes & times, Route::TTurns & turns, - vector<m2::PointD> & routeGeometry, + vector<Junction> & routeGeometry, my::Cancellable const & cancellable) { times.clear(); @@ -159,10 +159,7 @@ void BicycleDirectionsEngine::Generate(IRoadGraph const & graph, vector<Junction LoadedPathSegment pathSegment; if (inFeatureId.IsValid()) - { - LoadPathGeometry(inFeatureId, {prevJunction.GetPoint(), currJunction.GetPoint()}, - pathSegment); - } + LoadPathGeometry(inFeatureId, {prevJunction, currJunction}, pathSegment); m_adjacentEdges.insert(make_pair(inFeatureId.m_index, move(adjacentEdges))); m_pathSegments.push_back(move(pathSegment)); @@ -172,6 +169,7 @@ void BicycleDirectionsEngine::Generate(IRoadGraph const & graph, vector<Junction RouterDelegate delegate; Route::TTimes turnAnnotationTimes; Route::TStreets streetNames; + MakeTurnAnnotation(resultGraph, delegate, routeGeometry, turns, turnAnnotationTimes, streetNames); } @@ -183,7 +181,7 @@ Index::FeaturesLoaderGuard & BicycleDirectionsEngine::GetLoader(MwmSet::MwmId co } void BicycleDirectionsEngine::LoadPathGeometry(FeatureID const & featureId, - vector<m2::PointD> const & path, + vector<Junction> const & path, LoadedPathSegment & pathSegment) { pathSegment.Clear(); diff --git a/routing/bicycle_directions.hpp b/routing/bicycle_directions.hpp index 23ae01a11d..160e0520cf 100644 --- a/routing/bicycle_directions.hpp +++ b/routing/bicycle_directions.hpp @@ -28,12 +28,12 @@ public: // IDirectionsEngine override: void Generate(IRoadGraph const & graph, vector<Junction> const & path, Route::TTimes & times, - Route::TTurns & turns, vector<m2::PointD> & routeGeometry, + Route::TTurns & turns, vector<Junction> & routeGeometry, my::Cancellable const & cancellable) override; private: Index::FeaturesLoaderGuard & GetLoader(MwmSet::MwmId const & id); - void LoadPathGeometry(FeatureID const & featureId, vector<m2::PointD> const & path, + void LoadPathGeometry(FeatureID const & featureId, vector<Junction> const & path, LoadedPathSegment & pathSegment); TAdjacentEdgesMap m_adjacentEdges; diff --git a/routing/directions_engine.hpp b/routing/directions_engine.hpp index 1dd3ee7794..54ec9cdd4e 100644 --- a/routing/directions_engine.hpp +++ b/routing/directions_engine.hpp @@ -17,7 +17,7 @@ public: virtual void Generate(IRoadGraph const & graph, vector<Junction> const & path, Route::TTimes & times, Route::TTurns & turns, - vector<m2::PointD> & routeGeometry, + vector<Junction> & routeGeometry, my::Cancellable const & cancellable) = 0; protected: diff --git a/routing/loaded_path_segment.hpp b/routing/loaded_path_segment.hpp index be36aa9ecb..7b5dad4741 100644 --- a/routing/loaded_path_segment.hpp +++ b/routing/loaded_path_segment.hpp @@ -1,6 +1,7 @@ #pragma once #include "routing/osrm_helpers.hpp" +#include "routing/road_graph.hpp" #include "routing/turns.hpp" #include "routing/turn_candidate.hpp" @@ -25,7 +26,7 @@ struct FeatureGraphNode; */ struct LoadedPathSegment { - vector<m2::PointD> m_path; + vector<Junction> m_path; vector<turns::SingleLaneInfo> m_lanes; string m_name; TEdgeWeight m_weight; /*!< Time in seconds to pass the segment. */ diff --git a/routing/osrm_path_segment_factory.cpp b/routing/osrm_path_segment_factory.cpp index 6232cc75a2..c861707003 100644 --- a/routing/osrm_path_segment_factory.cpp +++ b/routing/osrm_path_segment_factory.cpp @@ -1,4 +1,5 @@ #include "routing/osrm_path_segment_factory.hpp" +#include "routing/road_graph.hpp" #include "routing/routing_mapping.hpp" #include "indexer/feature.hpp" @@ -56,13 +57,13 @@ void LoadPathGeometry(buffer_vector<TSeg, 8> const & buffer, size_t startIndex, if (startIdx < endIdx) { for (auto idx = startIdx; idx <= endIdx; ++idx) - loadPathGeometry.m_path.push_back(ft.GetPoint(idx)); + loadPathGeometry.m_path.push_back(routing::Junction(ft.GetPoint(idx), feature::kDefaultAltitudeMeters)); } else { // I use big signed type because endIdx can be 0. for (int64_t idx = startIdx; idx >= static_cast<int64_t>(endIdx); --idx) - loadPathGeometry.m_path.push_back(ft.GetPoint(idx)); + loadPathGeometry.m_path.push_back(routing::Junction(ft.GetPoint(idx), feature::kDefaultAltitudeMeters)); } // Load lanes if it is a last segment before junction. diff --git a/routing/osrm_router.cpp b/routing/osrm_router.cpp index 4d94c0d33c..402853ffc7 100644 --- a/routing/osrm_router.cpp +++ b/routing/osrm_router.cpp @@ -153,9 +153,15 @@ public: double GetPathLength() const override { return m_rawResult.shortestPathLength; } - m2::PointD const & GetStartPoint() const override { return m_rawResult.sourceEdge.segmentPoint; } + Junction const & GetStartPoint() const override + { + return Junction(m_rawResult.sourceEdge.segmentPoint, feature::kDefaultAltitudeMeters); + } - m2::PointD const & GetEndPoint() const override { return m_rawResult.targetEdge.segmentPoint; } + Junction const & GetEndPoint() const override + { + return Junction(m_rawResult.targetEdge.segmentPoint, feature::kDefaultAltitudeMeters); + } OSRMRoutingResult(Index const & index, RoutingMapping & mapping, RawRoutingResult & result) : m_rawResult(result), m_index(index), m_routingMapping(mapping) @@ -325,13 +331,18 @@ OsrmRouter::ResultCode OsrmRouter::MakeRouteFromCrossesPath(TCheckedPath const & Route::TTurns mwmTurnsDir; Route::TTimes mwmTimes; Route::TStreets mwmStreets; - vector<m2::PointD> mwmPoints; + vector<Junction> mwmJunctions; + OSRMRoutingResult resultGraph(*m_pIndex, *mwmMapping, routingResult); - if (MakeTurnAnnotation(resultGraph, delegate, mwmPoints, mwmTurnsDir, mwmTimes, mwmStreets) != NoError) + if (MakeTurnAnnotation(resultGraph, delegate, mwmJunctions, mwmTurnsDir, mwmTimes, mwmStreets) != NoError) { LOG(LWARNING, ("Can't load road path data from disk for", mwmMapping->GetCountryName())); return RouteNotFound; } + + vector<m2::PointD> mwmPoints; + JunctionsToPoints(mwmJunctions, mwmPoints); + // Connect annotated route. auto const pSize = static_cast<uint32_t>(points.size()); for (auto turn : mwmTurnsDir) @@ -494,15 +505,18 @@ OsrmRouter::ResultCode OsrmRouter::CalculateRoute(m2::PointD const & startPoint, Route::TTurns turnsDir; Route::TTimes times; Route::TStreets streets; - vector<m2::PointD> points; + vector<Junction> junctions; OSRMRoutingResult resultGraph(*m_pIndex, *startMapping, routingResult); - if (MakeTurnAnnotation(resultGraph, delegate, points, turnsDir, times, streets) != NoError) + if (MakeTurnAnnotation(resultGraph, delegate, junctions, turnsDir, times, streets) != NoError) { LOG(LWARNING, ("Can't load road path data from disk!")); return RouteNotFound; } + vector<m2::PointD> points; + JunctionsToPoints(junctions, points); + route.SetGeometry(points.begin(), points.end()); route.SwapTurnInstructions(turnsDir); route.SwapSectionTimes(times); diff --git a/routing/pedestrian_directions.cpp b/routing/pedestrian_directions.cpp index 87373127b0..30660d3c1a 100644 --- a/routing/pedestrian_directions.cpp +++ b/routing/pedestrian_directions.cpp @@ -20,14 +20,6 @@ bool HasType(uint32_t type, feature::TypesHolder const & types) } return false; } - -void Convert(vector<routing::Junction> const & path, vector<m2::PointD> & geometry) -{ - size_t const pathSize = path.size(); - geometry.resize(pathSize); - for (size_t i = 0; i < pathSize; ++i) - geometry[i] = path[i].GetPoint(); -} } // namespace namespace routing @@ -42,7 +34,7 @@ PedestrianDirectionsEngine::PedestrianDirectionsEngine() void PedestrianDirectionsEngine::Generate(IRoadGraph const & graph, vector<Junction> const & path, Route::TTimes & times, Route::TTurns & turns, - vector<m2::PointD> & routeGeometry, + vector<Junction> & routeGeometry, my::Cancellable const & cancellable) { times.clear(); @@ -64,7 +56,7 @@ void PedestrianDirectionsEngine::Generate(IRoadGraph const & graph, vector<Junct } CalculateTurns(graph, routeEdges, turns, cancellable); - Convert(path, routeGeometry); + routeGeometry = path; } void PedestrianDirectionsEngine::CalculateTurns(IRoadGraph const & graph, diff --git a/routing/pedestrian_directions.hpp b/routing/pedestrian_directions.hpp index c00af9b3eb..93cf0c91fd 100644 --- a/routing/pedestrian_directions.hpp +++ b/routing/pedestrian_directions.hpp @@ -12,7 +12,7 @@ public: // IDirectionsEngine override: void Generate(IRoadGraph const & graph, vector<Junction> const & path, Route::TTimes & times, - Route::TTurns & turns, vector<m2::PointD> & routeGeometry, + Route::TTurns & turns, vector<Junction> & routeGeometry, my::Cancellable const & cancellable) override; private: diff --git a/routing/road_graph.hpp b/routing/road_graph.hpp index 5bab78a5a5..880377dc71 100644 --- a/routing/road_graph.hpp +++ b/routing/road_graph.hpp @@ -265,4 +265,18 @@ private: IRoadGraph::RoadInfo MakeRoadInfoForTesting(bool bidirectional, double speedKMPH, initializer_list<m2::PointD> const & points); + +inline void JunctionsToPoints(vector<Junction> const & junctions, vector<m2::PointD> & points) +{ + points.resize(junctions.size()); + for (size_t i = 0; i < junctions.size(); ++i) + points[i] = junctions[i].GetPoint(); +} + +inline void JunctionsToAltitudes(vector<Junction> const & junctions, feature::TAltitudes & altitudes) +{ + altitudes.resize(junctions.size()); + for (size_t i = 0; i < junctions.size(); ++i) + altitudes[i] = junctions[i].GetAltitude(); +} } // namespace routing diff --git a/routing/road_graph_router.cpp b/routing/road_graph_router.cpp index dddfb17fc1..f449e70531 100644 --- a/routing/road_graph_router.cpp +++ b/routing/road_graph_router.cpp @@ -243,17 +243,18 @@ void RoadGraphRouter::ReconstructRoute(vector<Junction> && path, Route & route, Route::TTimes times; Route::TTurns turnsDir; - vector<m2::PointD> geometry; + vector<Junction> junctions; // @TODO(bykoianko) streetNames is not filled in Generate(). It should be done. Route::TStreets streetNames; if (m_directionsEngine) - m_directionsEngine->Generate(*m_roadGraph, path, times, turnsDir, geometry, cancellable); + m_directionsEngine->Generate(*m_roadGraph, path, times, turnsDir, junctions, cancellable); - feature::TAltitudes altitudes(path.size()); - for (size_t i = 0; i < path.size(); ++i) - altitudes[i] = path[i].GetAltitude(); + vector<m2::PointD> routeGeometry; + JunctionsToPoints(junctions, routeGeometry); + feature::TAltitudes altitudes; + JunctionsToAltitudes(junctions, altitudes); - route.SetGeometry(geometry.begin(), geometry.end()); + route.SetGeometry(routeGeometry.begin(), routeGeometry.end()); route.SwapSectionTimes(times); route.SwapTurnInstructions(turnsDir); route.SwapStreetNames(streetNames); diff --git a/routing/routing_result_graph.hpp b/routing/routing_result_graph.hpp index 07c482f80c..d815b228ec 100644 --- a/routing/routing_result_graph.hpp +++ b/routing/routing_result_graph.hpp @@ -1,6 +1,7 @@ #pragma once #include "routing/loaded_path_segment.hpp" +#include "routing/road_graph.hpp" #include "routing/turn_candidate.hpp" #include "std/vector.hpp" @@ -24,8 +25,8 @@ public: m2::PointD const & junctionPoint, size_t & ingoingCount, TurnCandidates & outgoingTurns) const = 0; virtual double GetPathLength() const = 0; - virtual m2::PointD const & GetStartPoint() const = 0; - virtual m2::PointD const & GetEndPoint() const = 0; + virtual Junction const & GetStartPoint() const = 0; + virtual Junction const & GetEndPoint() const = 0; virtual ~IRoutingResult() = default; }; diff --git a/routing/routing_tests/turns_generator_test.cpp b/routing/routing_tests/turns_generator_test.cpp index e394922230..c52d20aead 100644 --- a/routing/routing_tests/turns_generator_test.cpp +++ b/routing/routing_tests/turns_generator_test.cpp @@ -123,11 +123,11 @@ UNIT_TEST(TestFixupTurns) m2::RectD const kSquareNearZero = MercatorBounds::MetresToXY(kSquareCenterLonLat.x, kSquareCenterLonLat.y, kHalfSquareSideMeters); // Removing a turn in case staying on a roundabout. - vector<m2::PointD> const pointsMerc1 = { - { kSquareNearZero.minX(), kSquareNearZero.minY()}, - { kSquareNearZero.minX(), kSquareNearZero.maxY() }, - { kSquareNearZero.maxX(), kSquareNearZero.maxY() }, - { kSquareNearZero.maxX(), kSquareNearZero.minY() } + vector<Junction> const pointsMerc1 = { + {{ kSquareNearZero.minX(), kSquareNearZero.minY() }, feature::kDefaultAltitudeMeters}, + {{ kSquareNearZero.minX(), kSquareNearZero.maxY() }, feature::kDefaultAltitudeMeters}, + {{ kSquareNearZero.maxX(), kSquareNearZero.maxY() }, feature::kDefaultAltitudeMeters}, + {{ kSquareNearZero.maxX(), kSquareNearZero.minY() }, feature::kDefaultAltitudeMeters}, }; // The constructor TurnItem(uint32_t idx, TurnDirection t, uint32_t exitNum = 0) // is used for initialization of vector<TurnItem> below. @@ -143,10 +143,11 @@ UNIT_TEST(TestFixupTurns) TEST_EQUAL(turnsDir1, expectedTurnDir1, ()); // Merging turns which are close to each other. - vector<m2::PointD> const pointsMerc2 = { - { kSquareNearZero.minX(), kSquareNearZero.minY()}, - { kSquareCenterLonLat.x, kSquareCenterLonLat.y }, - { kSquareNearZero.maxX(), kSquareNearZero.maxY() }}; + vector<Junction> const pointsMerc2 = { + {{ kSquareNearZero.minX(), kSquareNearZero.minY()}, feature::kDefaultAltitudeMeters}, + {{ kSquareCenterLonLat.x, kSquareCenterLonLat.y }, feature::kDefaultAltitudeMeters}, + {{ kSquareNearZero.maxX(), kSquareNearZero.maxY() }, feature::kDefaultAltitudeMeters}, + }; Route::TTurns turnsDir2 = {{0, TurnDirection::GoStraight}, {1, TurnDirection::TurnLeft}, {2, TurnDirection::ReachedYourDestination}}; @@ -157,10 +158,11 @@ UNIT_TEST(TestFixupTurns) TEST_EQUAL(turnsDir2, expectedTurnDir2, ()); // No turn is removed. - vector<m2::PointD> const pointsMerc3 = { - { kSquareNearZero.minX(), kSquareNearZero.minY()}, - { kSquareNearZero.minX(), kSquareNearZero.maxY() }, - { kSquareNearZero.maxX(), kSquareNearZero.maxY() }}; + vector<Junction> const pointsMerc3 = { + {{ kSquareNearZero.minX(), kSquareNearZero.minY()}, feature::kDefaultAltitudeMeters}, + {{ kSquareNearZero.minX(), kSquareNearZero.maxY() }, feature::kDefaultAltitudeMeters}, + {{ kSquareNearZero.maxX(), kSquareNearZero.maxY() }, feature::kDefaultAltitudeMeters}, + }; Route::TTurns turnsDir3 = {{1, TurnDirection::TurnRight}, {2, TurnDirection::ReachedYourDestination}}; diff --git a/routing/turns_generator.cpp b/routing/turns_generator.cpp index 3bd9e443a0..ad5bcda522 100644 --- a/routing/turns_generator.cpp +++ b/routing/turns_generator.cpp @@ -193,7 +193,7 @@ TurnDirection FindDirectionByAngle(vector<pair<double, TurnDirection>> const & l * shift belongs to a range [0, abs(end - start)]. * \return an ingoing or outgoing point for a turn calculation. */ -m2::PointD GetPointForTurn(vector<m2::PointD> const & path, m2::PointD const & junctionPoint, +m2::PointD GetPointForTurn(vector<Junction> const & path, m2::PointD const & junctionPoint, size_t const maxPointsCount, double const minDistMeters, function<size_t(const size_t start, const size_t end, const size_t shift)> GetPointIndex) { @@ -210,7 +210,7 @@ m2::PointD GetPointForTurn(vector<m2::PointD> const & path, m2::PointD const & j for (size_t i = 1; i <= usedFtPntNum; ++i) { - nextPoint = path[GetPointIndex(0, numSegPoints, i)]; + nextPoint = path[GetPointIndex(0, numSegPoints, i)].GetPoint(); // TODO The code below is a stub for compatability with older versions with this function. // Remove it, fix tests cases when it works (integration test @@ -254,7 +254,7 @@ bool TurnInfo::IsSegmentsValid() const } IRouter::ResultCode MakeTurnAnnotation(turns::IRoutingResult const & result, - RouterDelegate const & delegate, vector<m2::PointD> & points, + RouterDelegate const & delegate, vector<Junction> & junctions, Route::TTurns & turnsDir, Route::TTimes & times, Route::TStreets & streets) { @@ -279,13 +279,13 @@ IRouter::ResultCode MakeTurnAnnotation(turns::IRoutingResult const & result, // Street names. I put empty names too, to avoid freezing old street name while riding on // unnamed street. - streets.emplace_back(max(points.size(), static_cast<size_t>(1)) - 1, loadedSegmentIt->m_name); + streets.emplace_back(max(junctions.size(), static_cast<size_t>(1)) - 1, loadedSegmentIt->m_name); // Turns information. - if (!points.empty() && skipTurnSegments == 0) + if (!junctions.empty() && skipTurnSegments == 0) { turns::TurnItem turnItem; - turnItem.m_index = static_cast<uint32_t>(points.size() - 1); + turnItem.m_index = static_cast<uint32_t>(junctions.size() - 1); size_t segmentIndex = distance(loadedSegments.begin(), loadedSegmentIt); skipTurnSegments = CheckUTurnOnRoute(loadedSegments, segmentIndex, turnItem); @@ -297,14 +297,14 @@ IRouter::ResultCode MakeTurnAnnotation(turns::IRoutingResult const & result, #ifdef DEBUG double distMeters = 0.0; - for (size_t k = lastIdx + 1; k < points.size(); ++k) - distMeters += MercatorBounds::DistanceOnEarth(points[k - 1], points[k]); + for (size_t k = lastIdx + 1; k < junctions.size(); ++k) + distMeters += MercatorBounds::DistanceOnEarth(junctions[k - 1].GetPoint(), junctions[k].GetPoint()); LOG(LDEBUG, ("Speed:", 3.6 * distMeters / nodeTimeSeconds, "kmph; Dist:", distMeters, "Time:", - nodeTimeSeconds, "s", lastIdx, "e", points.size(), "source:", + nodeTimeSeconds, "s", lastIdx, "e", junctions.size(), "source:", turnItem.m_sourceName, "target:", turnItem.m_targetName)); - lastIdx = points.size(); + lastIdx = junctions.size(); #endif - times.push_back(Route::TTimeItem(points.size(), estimatedTime)); + times.push_back(Route::TTimeItem(junctions.size(), estimatedTime)); // Lane information. if (turnItem.m_turn != turns::TurnDirection::NoTurn) @@ -319,22 +319,22 @@ IRouter::ResultCode MakeTurnAnnotation(turns::IRoutingResult const & result, --skipTurnSegments; // Path geometry. - points.insert(points.end(), loadedSegmentIt->m_path.begin(), loadedSegmentIt->m_path.end()); + junctions.insert(junctions.end(), loadedSegmentIt->m_path.begin(), loadedSegmentIt->m_path.end()); } - // Path found. Points will be replaced by start and end edges points. - if (points.size() == 1) - points.push_back(points.front()); + // Path found. Points will be replaced by start and end edges junctions. + if (junctions.size() == 1) + junctions.push_back(junctions.front()); - if (points.size() < 2) + if (junctions.size() < 2) return IRouter::ResultCode::RouteNotFound; - points.front() = result.GetStartPoint(); - points.back() = result.GetEndPoint(); + junctions.front() = result.GetStartPoint(); + junctions.back() = result.GetEndPoint(); - times.push_back(Route::TTimeItem(points.size() - 1, estimatedTime)); - turnsDir.emplace_back(turns::TurnItem(static_cast<uint32_t>(points.size()) - 1, turns::TurnDirection::ReachedYourDestination)); - turns::FixupTurns(points, turnsDir); + times.push_back(Route::TTimeItem(junctions.size() - 1, estimatedTime)); + turnsDir.emplace_back(turns::TurnItem(static_cast<uint32_t>(junctions.size()) - 1, turns::TurnDirection::ReachedYourDestination)); + turns::FixupTurns(junctions, turnsDir); #ifdef DEBUG for (auto t : turnsDir) @@ -349,7 +349,7 @@ IRouter::ResultCode MakeTurnAnnotation(turns::IRoutingResult const & result, { double dist = 0; for (size_t i = last + 1; i <= t.first; ++i) - dist += MercatorBounds::DistanceOnEarth(points[i - 1], points[i]); + dist += MercatorBounds::DistanceOnEarth(junctions[i - 1].GetPoint(), junctions[i].GetPoint()); double time = t.second - lastTime; @@ -376,23 +376,23 @@ double CalculateMercatorDistanceAlongPath(uint32_t startPointIndex, uint32_t end return mercatorDistanceBetweenTurns; } -void FixupTurns(vector<m2::PointD> const & points, Route::TTurns & turnsDir) +void FixupTurns(vector<Junction> const & junctions, Route::TTurns & turnsDir) { double const kMergeDistMeters = 30.0; // For turns that are not EnterRoundAbout exitNum is always equal to zero. - // If a turn is EnterRoundAbout exitNum is a number of turns between two points: + // If a turn is EnterRoundAbout exitNum is a number of turns between two junctions: // (1) the route enters to the roundabout; // (2) the route leaves the roundabout; uint32_t exitNum = 0; - // If a roundabout is worked up the roundabout value points to the turn + // If a roundabout is worked up the roundabout value junctions to the turn // of the enter to the roundabout. If not, roundabout is equal to nullptr. TurnItem * roundabout = nullptr; - auto routeDistanceMeters = [&points](uint32_t start, uint32_t end) + auto routeDistanceMeters = [&junctions](uint32_t start, uint32_t end) { double res = 0.0; for (uint32_t i = start + 1; i < end; ++i) - res += MercatorBounds::DistanceOnEarth(points[i - 1], points[i]); + res += MercatorBounds::DistanceOnEarth(junctions[i - 1].GetPoint(), junctions[i].GetPoint()); return res; }; @@ -568,11 +568,11 @@ void GetTurnDirection(IRoutingResult const & result, TurnInfo & turnInfo, TurnIt ASSERT(!turnInfo.m_ingoing.m_path.empty(), ()); ASSERT(!turnInfo.m_outgoing.m_path.empty(), ()); - ASSERT_LESS(MercatorBounds::DistanceOnEarth(turnInfo.m_ingoing.m_path.back(), - turnInfo.m_outgoing.m_path.front()), + ASSERT_LESS(MercatorBounds::DistanceOnEarth(turnInfo.m_ingoing.m_path.back().GetPoint(), + turnInfo.m_outgoing.m_path.front().GetPoint()), kFeaturesNearTurnMeters, ()); - m2::PointD const junctionPoint = turnInfo.m_ingoing.m_path.back(); + m2::PointD const junctionPoint = turnInfo.m_ingoing.m_path.back().GetPoint(); m2::PointD const ingoingPoint = GetPointForTurn(turnInfo.m_ingoing.m_path, junctionPoint, kMaxPointsCount, kMinDistMeters, GetIngoingPointIndex); @@ -592,7 +592,7 @@ void GetTurnDirection(IRoutingResult const & result, TurnInfo & turnInfo, TurnIt return; ASSERT_GREATER(turnInfo.m_ingoing.m_path.size(), 1, ()); - m2::PointD const ingoingPointOneSegment = turnInfo.m_ingoing.m_path[turnInfo.m_ingoing.m_path.size() - 2]; + m2::PointD const ingoingPointOneSegment = turnInfo.m_ingoing.m_path[turnInfo.m_ingoing.m_path.size() - 2].GetPoint(); TurnCandidates nodes; size_t ingoingCount; result.GetPossibleTurns(turnInfo.m_ingoing.m_nodeId, ingoingPointOneSegment, junctionPoint, @@ -702,8 +702,8 @@ size_t CheckUTurnOnRoute(TUnpackedPathSegments const & segments, if (path[path.size() - 2] == checkedSegment.m_path[1]) return 0; - m2::PointD const v1 = path[path.size() - 1] - path[path.size() - 2]; - m2::PointD const v2 = checkedSegment.m_path[1] - checkedSegment.m_path[0]; + m2::PointD const v1 = path[path.size() - 1].GetPoint() - path[path.size() - 2].GetPoint(); + m2::PointD const v2 = checkedSegment.m_path[1].GetPoint() - checkedSegment.m_path[0].GetPoint(); auto angle = ang::TwoVectorsAngle(m2::PointD::Zero(), v1, v2); @@ -711,7 +711,7 @@ size_t CheckUTurnOnRoute(TUnpackedPathSegments const & segments, return 0; // Determine turn direction. - m2::PointD const junctionPoint = masterSegment.m_path.back(); + m2::PointD const junctionPoint = masterSegment.m_path.back().GetPoint(); m2::PointD const ingoingPoint = GetPointForTurn(masterSegment.m_path, junctionPoint, kMaxPointsCount, kMinDistMeters, GetIngoingPointIndex); diff --git a/routing/turns_generator.hpp b/routing/turns_generator.hpp index 80bd0e27b8..4ea146039a 100644 --- a/routing/turns_generator.hpp +++ b/routing/turns_generator.hpp @@ -43,7 +43,7 @@ using TGetIndexFunction = function<size_t(pair<size_t, size_t>)>; * \return routing operation result code. */ IRouter::ResultCode MakeTurnAnnotation(turns::IRoutingResult const & result, - RouterDelegate const & delegate, vector<m2::PointD> & points, + RouterDelegate const & delegate, vector<Junction> & points, Route::TTurns & turnsDir, Route::TTimes & times, Route::TStreets & streets); @@ -72,7 +72,7 @@ double CalculateMercatorDistanceAlongPath(uint32_t startPointIndex, uint32_t end * \brief Selects lanes which are recommended for an end user. */ void SelectRecommendedLanes(Route::TTurns & turnsDir); -void FixupTurns(vector<m2::PointD> const & points, Route::TTurns & turnsDir); +void FixupTurns(vector<Junction> const & points, Route::TTurns & turnsDir); inline size_t GetFirstSegmentPointIndex(pair<size_t, size_t> const & p) { return p.first; } TurnDirection InvertDirection(TurnDirection dir); |