Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2018-01-29 13:12:08 +0300
committermpimenov <mpimenov@users.noreply.github.com>2018-02-19 20:26:27 +0300
commitc345efacdd427ee4888fefd581b8adcd8aeffb50 (patch)
tree3d8755fe6b12e652d6771533391a041603a24e72 /routing
parentf167dec07518e73aad946f4e0f4fb65b7b9a028f (diff)
Removing ReconstructPath().
Diffstat (limited to 'routing')
-rw-r--r--routing/CMakeLists.txt1
-rw-r--r--routing/bicycle_directions.cpp14
-rw-r--r--routing/bicycle_directions.hpp4
-rw-r--r--routing/directions_engine.cpp64
-rw-r--r--routing/directions_engine.hpp14
-rw-r--r--routing/index_road_graph.hpp1
-rw-r--r--routing/pedestrian_directions.cpp12
-rw-r--r--routing/pedestrian_directions.hpp4
-rw-r--r--routing/routing_helpers.cpp2
-rw-r--r--routing/routing_helpers.hpp4
10 files changed, 19 insertions, 101 deletions
diff --git a/routing/CMakeLists.txt b/routing/CMakeLists.txt
index 50bdd16888..1d86df5670 100644
--- a/routing/CMakeLists.txt
+++ b/routing/CMakeLists.txt
@@ -29,7 +29,6 @@ set(
cross_mwm_graph.hpp
cross_mwm_ids.hpp
cross_mwm_index_graph.hpp
- directions_engine.cpp
directions_engine.hpp
edge_estimator.cpp
edge_estimator.hpp
diff --git a/routing/bicycle_directions.cpp b/routing/bicycle_directions.cpp
index 5822077014..362d52741d 100644
--- a/routing/bicycle_directions.cpp
+++ b/routing/bicycle_directions.cpp
@@ -164,7 +164,7 @@ BicycleDirectionsEngine::BicycleDirectionsEngine(Index const & index, shared_ptr
CHECK(m_numMwmIds, ());
}
-bool BicycleDirectionsEngine::Generate(RoadGraphBase const & graph, vector<Junction> const & path,
+bool BicycleDirectionsEngine::Generate(IndexRoadGraph const & graph, vector<Junction> const & path,
my::Cancellable const & cancellable, Route::TTurns & turns,
Route::TStreets & streetNames,
vector<Junction> & routeGeometry, vector<Segment> & segments)
@@ -178,15 +178,11 @@ bool BicycleDirectionsEngine::Generate(RoadGraphBase const & graph, vector<Junct
size_t const pathSize = path.size();
// Note. According to Route::IsValid() method route of zero or one point is invalid.
- if (pathSize < 1)
+ if (pathSize <= 1)
return false;
IRoadGraph::TEdgeVector routeEdges;
- if (!ReconstructPath(graph, path, routeEdges, cancellable))
- {
- LOG(LWARNING, ("Can't reconstruct path."));
- return false;
- }
+ graph.GetRouteEdges(routeEdges);
if (routeEdges.empty())
return false;
@@ -199,7 +195,7 @@ bool BicycleDirectionsEngine::Generate(RoadGraphBase const & graph, vector<Junct
if (cancellable.IsCancelled())
return false;
- RoutingResult resultGraph(routeEdges, m_adjacentEdges, m_pathSegments);
+ ::RoutingResult resultGraph(routeEdges, m_adjacentEdges, m_pathSegments);
RouterDelegate delegate;
MakeTurnAnnotation(resultGraph, delegate, routeGeometry, turns, streetNames, segments);
@@ -297,7 +293,7 @@ void BicycleDirectionsEngine::GetEdges(RoadGraphBase const & graph, Junction con
}
void BicycleDirectionsEngine::FillPathSegmentsAndAdjacentEdgesMap(
- RoadGraphBase const & graph, vector<Junction> const & path,
+ IndexRoadGraph const & graph, vector<Junction> const & path,
IRoadGraph::TEdgeVector const & routeEdges, my::Cancellable const & cancellable)
{
size_t const pathSize = path.size();
diff --git a/routing/bicycle_directions.hpp b/routing/bicycle_directions.hpp
index 897cbbc441..8f223d8323 100644
--- a/routing/bicycle_directions.hpp
+++ b/routing/bicycle_directions.hpp
@@ -30,7 +30,7 @@ public:
BicycleDirectionsEngine(Index const & index, std::shared_ptr<NumMwmIds> numMwmIds);
// IDirectionsEngine override:
- bool Generate(RoadGraphBase const & graph, vector<Junction> const & path,
+ bool Generate(IndexRoadGraph const & graph, vector<Junction> const & path,
my::Cancellable const & cancellable, Route::TTurns & turns,
Route::TStreets & streetNames, vector<Junction> & routeGeometry,
vector<Segment> & segments) override;
@@ -44,7 +44,7 @@ private:
turns::TurnCandidates & outgoingTurns);
/// \brief The method gathers sequence of segments according to IsJoint() method
/// and fills |m_adjacentEdges| and |m_pathSegments|.
- void FillPathSegmentsAndAdjacentEdgesMap(RoadGraphBase const & graph,
+ void FillPathSegmentsAndAdjacentEdgesMap(IndexRoadGraph const & graph,
std::vector<Junction> const & path,
IRoadGraph::TEdgeVector const & routeEdges,
my::Cancellable const & cancellable);
diff --git a/routing/directions_engine.cpp b/routing/directions_engine.cpp
deleted file mode 100644
index 17503b2cac..0000000000
--- a/routing/directions_engine.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-#include "routing/directions_engine.hpp"
-
-#include "geometry/mercator.hpp"
-
-#include "base/assert.hpp"
-
-namespace routing
-{
-bool IDirectionsEngine::ReconstructPath(RoadGraphBase const & graph, vector<Junction> const & path,
- vector<Edge> & routeEdges,
- my::Cancellable const & cancellable) const
-{
- routeEdges.clear();
- if (path.size() <= 1)
- return false;
-
- if (graph.IsRouteEdgesImplemented())
- {
- graph.GetRouteEdges(routeEdges);
- ASSERT_EQUAL(routeEdges.size() + 1, path.size(), ());
- return true;
- }
-
- routeEdges.reserve(path.size() - 1);
-
- Junction curr = path[0];
- vector<Edge> currEdges;
- for (size_t i = 1; i < path.size(); ++i)
- {
- if (cancellable.IsCancelled())
- return false;
-
- Junction const & next = path[i];
-
- currEdges.clear();
- graph.GetOutgoingEdges(curr, currEdges);
-
- bool found = false;
- for (auto const & e : currEdges)
- {
- if (AlmostEqualAbs(e.GetEndJunction(), next))
- {
- routeEdges.emplace_back(e);
- found = true;
- break;
- }
- }
-
- if (!found)
- {
- LOG(LERROR, ("Can't find next edge, curr:", MercatorBounds::ToLatLon(curr.GetPoint()),
- ", next:", MercatorBounds::ToLatLon(next.GetPoint()), ", edges size:",
- currEdges.size(), ", i:", i));
- return false;
- }
-
- curr = next;
- }
-
- ASSERT_EQUAL(routeEdges.size() + 1, path.size(), ());
-
- return true;
-}
-} // namespace routing
diff --git a/routing/directions_engine.hpp b/routing/directions_engine.hpp
index 274a5985cc..33d65bda0c 100644
--- a/routing/directions_engine.hpp
+++ b/routing/directions_engine.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include "routing/road_graph.hpp"
+#include "routing/index_road_graph.hpp"
#include "routing/road_point.hpp"
#include "routing/route.hpp"
#include "routing/segment.hpp"
@@ -18,22 +18,14 @@ class IDirectionsEngine
public:
virtual ~IDirectionsEngine() = default;
- // @TODO(bykoianko) When fields |m_turns|, |m_times|, |m_streets| and |m_traffic|
- // are removed from class Route the method Generate() should fill
+ // @TODO(bykoianko) Method Generate() should fill
// vector<RouteSegment> instead of corresponding arguments.
/// \brief Generates all args which are passed by reference.
/// \param path is points of the route. It should not be empty.
/// \returns true if fields passed by reference are filled correctly and false otherwise.
- virtual bool Generate(RoadGraphBase const & graph, vector<Junction> const & path,
+ virtual bool Generate(IndexRoadGraph const & graph, vector<Junction> const & path,
my::Cancellable const & cancellable, Route::TTurns & turns,
Route::TStreets & streetNames, vector<Junction> & routeGeometry,
vector<Segment> & segments) = 0;
-
-protected:
- /// \brief constructs route based on |graph| and |path|. Fills |routeEdges| with the route.
- /// \returns false in case of any errors while reconstruction, if reconstruction process
- /// was cancelled and in case of extremely short paths of 0 or 1 point. Returns true otherwise.
- bool ReconstructPath(RoadGraphBase const & graph, std::vector<Junction> const & path,
- std::vector<Edge> & routeEdges, my::Cancellable const & cancellable) const;
};
} // namespace routing
diff --git a/routing/index_road_graph.hpp b/routing/index_road_graph.hpp
index e425e5efa2..555367bb15 100644
--- a/routing/index_road_graph.hpp
+++ b/routing/index_road_graph.hpp
@@ -35,7 +35,6 @@ public:
private:
void GetEdges(Junction const & junction, bool isOutgoing, TEdgeVector & edges) const;
- Junction const & GetJunction(Segment const & segment, bool front) const;
std::vector<Segment> const & GetSegments(Junction const & junction, bool isOutgoing) const;
Index & m_index;
diff --git a/routing/pedestrian_directions.cpp b/routing/pedestrian_directions.cpp
index 855f36a202..2631be0a30 100644
--- a/routing/pedestrian_directions.cpp
+++ b/routing/pedestrian_directions.cpp
@@ -39,7 +39,7 @@ PedestrianDirectionsEngine::PedestrianDirectionsEngine(shared_ptr<NumMwmIds> num
{
}
-bool PedestrianDirectionsEngine::Generate(RoadGraphBase const & graph,
+bool PedestrianDirectionsEngine::Generate(IndexRoadGraph const & graph,
vector<Junction> const & path,
my::Cancellable const & cancellable,
Route::TTurns & turns, Route::TStreets & streetNames,
@@ -52,15 +52,11 @@ bool PedestrianDirectionsEngine::Generate(RoadGraphBase const & graph,
routeGeometry = path;
// Note. According to Route::IsValid() method route of zero or one point is invalid.
- if (path.size() < 1)
+ if (path.size() <= 1)
return false;
vector<Edge> routeEdges;
- if (!ReconstructPath(graph, path, routeEdges, cancellable))
- {
- LOG(LWARNING, ("Can't reconstruct path."));
- return false;
- }
+ graph.GetRouteEdges(routeEdges);
CalculateTurns(graph, routeEdges, turns, cancellable);
@@ -78,7 +74,7 @@ bool PedestrianDirectionsEngine::Generate(RoadGraphBase const & graph,
return true;
}
-void PedestrianDirectionsEngine::CalculateTurns(RoadGraphBase const & graph,
+void PedestrianDirectionsEngine::CalculateTurns(IndexRoadGraph const & graph,
vector<Edge> const & routeEdges,
Route::TTurns & turns,
my::Cancellable const & cancellable) const
diff --git a/routing/pedestrian_directions.hpp b/routing/pedestrian_directions.hpp
index 7192ac8587..d772513483 100644
--- a/routing/pedestrian_directions.hpp
+++ b/routing/pedestrian_directions.hpp
@@ -15,13 +15,13 @@ public:
PedestrianDirectionsEngine(std::shared_ptr<NumMwmIds> numMwmIds);
// IDirectionsEngine override:
- bool Generate(RoadGraphBase const & graph, vector<Junction> const & path,
+ bool Generate(IndexRoadGraph const & graph, vector<Junction> const & path,
my::Cancellable const & cancellable, Route::TTurns & turns,
Route::TStreets & streetNames, vector<Junction> & routeGeometry,
vector<Segment> & segments) override;
private:
- void CalculateTurns(RoadGraphBase const & graph, std::vector<Edge> const & routeEdges,
+ void CalculateTurns(IndexRoadGraph const & graph, std::vector<Edge> const & routeEdges,
Route::TTurns & turnsDir, my::Cancellable const & cancellable) const;
uint32_t const m_typeSteps;
diff --git a/routing/routing_helpers.cpp b/routing/routing_helpers.cpp
index fbeb29a25d..295a7ceb69 100644
--- a/routing/routing_helpers.cpp
+++ b/routing/routing_helpers.cpp
@@ -98,7 +98,7 @@ void FillSegmentInfo(vector<Segment> const & segments, vector<Junction> const &
}
}
-void ReconstructRoute(IDirectionsEngine & engine, RoadGraphBase const & graph,
+void ReconstructRoute(IDirectionsEngine & engine, IndexRoadGraph const & graph,
shared_ptr<TrafficStash> const & trafficStash,
my::Cancellable const & cancellable, vector<Junction> const & path,
Route::TTimes && times, Route & route)
diff --git a/routing/routing_helpers.hpp b/routing/routing_helpers.hpp
index 734c442dec..acf92e4f7d 100644
--- a/routing/routing_helpers.hpp
+++ b/routing/routing_helpers.hpp
@@ -1,7 +1,7 @@
#pragma once
#include "routing/directions_engine.hpp"
-#include "routing/road_graph.hpp"
+#include "routing/index_road_graph.hpp"
#include "routing/route.hpp"
#include "routing/traffic_stash.hpp"
@@ -34,7 +34,7 @@ void FillSegmentInfo(std::vector<Segment> const & segments, std::vector<Junction
Route::TTimes const & times, std::shared_ptr<TrafficStash> const & trafficStash,
std::vector<RouteSegment> & routeSegment);
-void ReconstructRoute(IDirectionsEngine & engine, RoadGraphBase const & graph,
+void ReconstructRoute(IDirectionsEngine & engine, IndexRoadGraph const & graph,
std::shared_ptr<TrafficStash> const & trafficStash,
my::Cancellable const & cancellable, std::vector<Junction> const & path,
Route::TTimes && times, Route & route);