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:
authorLev Dragunov <l.dragunov@corp.mail.ru>2015-08-06 21:16:43 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 03:00:21 +0300
commit30b30063a6ca50d918e6a44e5435ed3243a7cf82 (patch)
treed00551fd3f454a5ed3332b496072f08e9ed346dd /routing
parentf076cf02949282cdafdb348482cbf9c10f2fcd4b (diff)
Pedestrian map existence check.
Diffstat (limited to 'routing')
-rw-r--r--routing/road_graph_router.cpp30
-rw-r--r--routing/road_graph_router.hpp11
-rw-r--r--routing/router.hpp2
-rw-r--r--routing/routing_mapping.hpp1
4 files changed, 37 insertions, 7 deletions
diff --git a/routing/road_graph_router.cpp b/routing/road_graph_router.cpp
index b937e5eb16..485de31756 100644
--- a/routing/road_graph_router.cpp
+++ b/routing/road_graph_router.cpp
@@ -19,6 +19,9 @@
#include "base/assert.hpp"
+using platform::CountryFile;
+using platform::LocalCountryFile;
+
namespace routing
{
@@ -79,10 +82,13 @@ bool CheckMwmVersion(vector<pair<Edge, m2::PointD>> const & vicinities, vector<s
RoadGraphRouter::~RoadGraphRouter() {}
RoadGraphRouter::RoadGraphRouter(string const & name, Index & index,
+ TCountryFileFn const & countryFileFn,
unique_ptr<IVehicleModelFactory> && vehicleModelFactory,
unique_ptr<IRoutingAlgorithm> && algorithm,
unique_ptr<IDirectionsEngine> && directionsEngine)
: m_name(name)
+ , m_countryFileFn(countryFileFn)
+ , m_index(&index)
, m_algorithm(move(algorithm))
, m_roadGraph(make_unique<FeaturesRoadGraph>(index, move(vehicleModelFactory)))
, m_directionsEngine(move(directionsEngine))
@@ -94,11 +100,27 @@ void RoadGraphRouter::ClearState()
m_roadGraph->ClearState();
}
+bool RoadGraphRouter::CheckMapExistence(m2::PointD const & point, Route & route) const
+{
+ string fileName = m_countryFileFn(point);
+ LocalCountryFile localCountryFile = m_index->GetMwmHandleByCountryFile(CountryFile(fileName)).GetInfo()->GetLocalFile();
+ if (!HasOptions(localCountryFile.GetFiles(), MapOptions::Map))
+ {
+ route.AddAbsentCountry(fileName);
+ return false;
+ }
+ return true;
+}
+
IRouter::ResultCode RoadGraphRouter::CalculateRoute(m2::PointD const & startPoint,
m2::PointD const & /* startDirection */,
m2::PointD const & finalPoint,
RouterDelegate const & delegate, Route & route)
{
+
+ if (!CheckMapExistence(startPoint, route) || !CheckMapExistence(finalPoint, route))
+ return RouteFileNotExist;
+
vector<pair<Edge, m2::PointD>> finalVicinity;
m_roadGraph->FindClosestEdges(finalPoint, kMaxRoadCandidates, finalVicinity);
@@ -184,21 +206,21 @@ void RoadGraphRouter::ReconstructRoute(vector<Junction> && path, Route & route,
route.SetTurnInstructionsGeometry(turnsGeom);
}
-unique_ptr<IRouter> CreatePedestrianAStarRouter(Index & index)
+unique_ptr<IRouter> CreatePedestrianAStarRouter(Index & index, TCountryFileFn const & countryFileFn)
{
unique_ptr<IVehicleModelFactory> vehicleModelFactory(new PedestrianModelFactory());
unique_ptr<IRoutingAlgorithm> algorithm(new AStarRoutingAlgorithm());
unique_ptr<IDirectionsEngine> directionsEngine(new PedestrianDirectionsEngine());
- unique_ptr<IRouter> router(new RoadGraphRouter("astar-pedestrian", index, move(vehicleModelFactory), move(algorithm), move(directionsEngine)));
+ unique_ptr<IRouter> router(new RoadGraphRouter("astar-pedestrian", index, countryFileFn, move(vehicleModelFactory), move(algorithm), move(directionsEngine)));
return router;
}
-unique_ptr<IRouter> CreatePedestrianAStarBidirectionalRouter(Index & index)
+unique_ptr<IRouter> CreatePedestrianAStarBidirectionalRouter(Index & index, TCountryFileFn const & countryFileFn)
{
unique_ptr<IVehicleModelFactory> vehicleModelFactory(new PedestrianModelFactory());
unique_ptr<IRoutingAlgorithm> algorithm(new AStarBidirectionalRoutingAlgorithm());
unique_ptr<IDirectionsEngine> directionsEngine(new PedestrianDirectionsEngine());
- unique_ptr<IRouter> router(new RoadGraphRouter("astar-bidirectional-pedestrian", index, move(vehicleModelFactory), move(algorithm), move(directionsEngine)));
+ unique_ptr<IRouter> router(new RoadGraphRouter("astar-bidirectional-pedestrian", index, countryFileFn, move(vehicleModelFactory), move(algorithm), move(directionsEngine)));
return router;
}
diff --git a/routing/road_graph_router.hpp b/routing/road_graph_router.hpp
index 048852d7a5..12c1d722e2 100644
--- a/routing/road_graph_router.hpp
+++ b/routing/road_graph_router.hpp
@@ -24,6 +24,7 @@ class RoadGraphRouter : public IRouter
{
public:
RoadGraphRouter(string const & name, Index & index,
+ TCountryFileFn const & countryFileFn,
unique_ptr<IVehicleModelFactory> && vehicleModelFactory,
unique_ptr<IRoutingAlgorithm> && algorithm,
unique_ptr<IDirectionsEngine> && directionsEngine);
@@ -40,13 +41,19 @@ private:
void ReconstructRoute(vector<Junction> && junctions, Route & route,
my::Cancellable const & cancellable) const;
+ /// Checks existance and add absent maps to route.
+ /// Returns true if map exists
+ bool CheckMapExistence(m2::PointD const & point, Route & route) const;
+
string const m_name;
+ TCountryFileFn const m_countryFileFn;
+ Index * m_index;
unique_ptr<IRoutingAlgorithm> const m_algorithm;
unique_ptr<IRoadGraph> const m_roadGraph;
unique_ptr<IDirectionsEngine> const m_directionsEngine;
};
-unique_ptr<IRouter> CreatePedestrianAStarRouter(Index & index);
+unique_ptr<IRouter> CreatePedestrianAStarRouter(Index & index, TCountryFileFn const & countryFileFn);
-unique_ptr<IRouter> CreatePedestrianAStarBidirectionalRouter(Index & index);
+unique_ptr<IRouter> CreatePedestrianAStarBidirectionalRouter(Index & index, TCountryFileFn const & countryFileFn);
} // namespace routing
diff --git a/routing/router.hpp b/routing/router.hpp
index 1968921828..c5dcf0a467 100644
--- a/routing/router.hpp
+++ b/routing/router.hpp
@@ -12,6 +12,8 @@
namespace routing
{
+using TCountryFileFn = function<string(m2::PointD const &)>;
+
class Route;
/// Routing engine type.
diff --git a/routing/routing_mapping.hpp b/routing/routing_mapping.hpp
index e81cba8bdd..8741a3bc78 100644
--- a/routing/routing_mapping.hpp
+++ b/routing/routing_mapping.hpp
@@ -20,7 +20,6 @@ class LocalCountryFile;
namespace routing
{
using TDataFacade = OsrmDataFacade<QueryEdge::EdgeData>;
-using TCountryFileFn = function<string(m2::PointD const &)>;
/// Datamapping and facade for single MWM and MWM.routing file
struct RoutingMapping