diff --git a/map/framework.cpp b/map/framework.cpp index 2ecddda15f..fc6d551a0d 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -8,8 +8,8 @@ #include "defines.hpp" #include "private.h" +#include "routing/car_router.hpp" #include "routing/online_absent_fetcher.hpp" -#include "routing/osrm_router.hpp" #include "routing/road_graph_router.hpp" #include "routing/route.hpp" #include "routing/routing_algorithm.hpp" @@ -2398,8 +2398,8 @@ void Framework::SetRouterImpl(RouterType type) return m_model.GetIndex().GetMwmIdByCountryFile(CountryFile(countryFile)).IsAlive(); }; - router.reset(new OsrmRouter(&m_model.GetIndex(), countryFileGetter, - CreateCarAStarBidirectionalRouter(m_model.GetIndex(), countryFileGetter))); + router.reset(new CarRouter(&m_model.GetIndex(), countryFileGetter, + CreateCarAStarBidirectionalRouter(m_model.GetIndex(), countryFileGetter))); fetcher.reset(new OnlineAbsentCountriesFetcher(countryFileGetter, localFileChecker)); m_routingSession.SetRoutingSettings(routing::GetCarRoutingSettings()); } @@ -2551,8 +2551,8 @@ RouterType Framework::GetBestRouter(m2::PointD const & startPoint, m2::PointD co { return m_infoGetter->GetRegionCountryId(pt); }; - if (!OsrmRouter::CheckRoutingAbility(startPoint, finalPoint, countryFileGetter, - &m_model.GetIndex())) + if (!CarRouter::CheckRoutingAbility(startPoint, finalPoint, countryFileGetter, + &m_model.GetIndex())) { return RouterType::Pedestrian; } diff --git a/routing/osrm_router.cpp b/routing/car_router.cpp similarity index 89% rename from routing/osrm_router.cpp rename to routing/car_router.cpp index 31c8b87eaf..e773852941 100644 --- a/routing/osrm_router.cpp +++ b/routing/car_router.cpp @@ -1,10 +1,10 @@ +#include "routing/car_router.hpp" #include "routing/cross_mwm_router.hpp" #include "routing/loaded_path_segment.hpp" #include "routing/online_cross_fetcher.hpp" #include "routing/osrm2feature_map.hpp" #include "routing/osrm_helpers.hpp" #include "routing/osrm_path_segment_factory.hpp" -#include "routing/osrm_router.hpp" #include "routing/road_graph_router.hpp" #include "routing/turns_generator.hpp" @@ -200,34 +200,35 @@ private: }; // static -bool OsrmRouter::CheckRoutingAbility(m2::PointD const & startPoint, m2::PointD const & finalPoint, - TCountryFileFn const & countryFileFn, Index * index) +bool CarRouter::CheckRoutingAbility(m2::PointD const & startPoint, m2::PointD const & finalPoint, + TCountryFileFn const & countryFileFn, Index * index) { RoutingIndexManager manager(countryFileFn, *index); return manager.GetMappingByPoint(startPoint)->IsValid() && manager.GetMappingByPoint(finalPoint)->IsValid(); } -OsrmRouter::OsrmRouter(Index * index, TCountryFileFn const & countryFileFn, - unique_ptr roadGraphRouter) +CarRouter::CarRouter(Index * index, TCountryFileFn const & countryFileFn, + unique_ptr roadGraphRouter) : m_pIndex(index), m_indexManager(countryFileFn, *index), m_roadGraphRouter(move(roadGraphRouter)) { } -string OsrmRouter::GetName() const +string CarRouter::GetName() const { return "vehicle"; } -void OsrmRouter::ClearState() +void CarRouter::ClearState() { m_cachedTargets.clear(); m_cachedTargetPoint = m2::PointD::Zero(); m_indexManager.Clear(); + m_roadGraphRouter->ClearState(); } -bool OsrmRouter::FindRouteFromCases(TFeatureGraphNodeVec const & source, TFeatureGraphNodeVec const & target, - RouterDelegate const & delegate, TRoutingMappingPtr & mapping, Route & route) +bool CarRouter::FindRouteFromCases(TFeatureGraphNodeVec const & source, TFeatureGraphNodeVec const & target, + RouterDelegate const & delegate, TRoutingMappingPtr & mapping, Route & route) { ASSERT(mapping, ()); @@ -304,9 +305,9 @@ void CalculatePhantomNodeForCross(TRoutingMappingPtr & mapping, FeatureGraphNode // TODO (ldragunov) move this function to cross mwm router // TODO (ldragunov) process case when the start and the finish points are placed on the same edge. -OsrmRouter::ResultCode OsrmRouter::MakeRouteFromCrossesPath(TCheckedPath const & path, - RouterDelegate const & delegate, - Route & route) +CarRouter::ResultCode CarRouter::MakeRouteFromCrossesPath(TCheckedPath const & path, + RouterDelegate const & delegate, + Route & route) { Route emptyRoute(GetName()); route.Swap(emptyRoute); @@ -327,10 +328,10 @@ OsrmRouter::ResultCode OsrmRouter::MakeRouteFromCrossesPath(TCheckedPath const & return NoError; } -OsrmRouter::ResultCode OsrmRouter::CalculateRoute(m2::PointD const & startPoint, - m2::PointD const & startDirection, - m2::PointD const & finalPoint, - RouterDelegate const & delegate, Route & route) +CarRouter::ResultCode CarRouter::CalculateRoute(m2::PointD const & startPoint, + m2::PointD const & startDirection, + m2::PointD const & finalPoint, + RouterDelegate const & delegate, Route & route) { my::HighResTimer timer(true); @@ -466,14 +467,14 @@ OsrmRouter::ResultCode OsrmRouter::CalculateRoute(m2::PointD const & startPoint, timer.Reset(); return code; } - return OsrmRouter::RouteNotFound; + return CarRouter::RouteNotFound; } } -IRouter::ResultCode OsrmRouter::FindPhantomNodes(m2::PointD const & point, - m2::PointD const & direction, - TFeatureGraphNodeVec & res, size_t maxCount, - TRoutingMappingPtr const & mapping) +IRouter::ResultCode CarRouter::FindPhantomNodes(m2::PointD const & point, + m2::PointD const & direction, + TFeatureGraphNodeVec & res, size_t maxCount, + TRoutingMappingPtr const & mapping) { ASSERT(mapping, ()); helpers::Point2PhantomNode getter(*mapping, *m_pIndex, direction); @@ -490,7 +491,7 @@ IRouter::ResultCode OsrmRouter::FindPhantomNodes(m2::PointD const & point, return NoError; } -bool OsrmRouter::IsEdgeIndexExisting(Index::MwmId const & mwmId) +bool CarRouter::IsEdgeIndexExisting(Index::MwmId const & mwmId) { MwmSet::MwmHandle const handle = m_pIndex->GetMwmHandleById(mwmId); if (!handle.IsAlive()) @@ -504,16 +505,17 @@ bool OsrmRouter::IsEdgeIndexExisting(Index::MwmId const & mwmId) if (value->GetHeader().GetFormat() < version::Format::v8) return false; - // @TODO Remove this string before merge. + // @TODO This section name will be defined in another PR. + // This const should be removed. string const EDGE_INDEX_FILE_TAG = "edgeidx"; if (value->m_cont.IsExist(EDGE_INDEX_FILE_TAG.c_str())) return true; return false; } -bool OsrmRouter::FindSingleRouteDispatcher(FeatureGraphNode const & source, FeatureGraphNode const & target, - RouterDelegate const & delegate, TRoutingMappingPtr & mapping, - Route & route) +bool CarRouter::FindSingleRouteDispatcher(FeatureGraphNode const & source, FeatureGraphNode const & target, + RouterDelegate const & delegate, TRoutingMappingPtr & mapping, + Route & route) { ASSERT_EQUAL(source.mwmId, target.mwmId, ()); ASSERT(m_pIndex, ()); @@ -525,6 +527,7 @@ bool OsrmRouter::FindSingleRouteDispatcher(FeatureGraphNode const & source, Feat // Probably it's better to keep if mwm had edge index section in mwmId. if (IsEdgeIndexExisting(source.mwmId) && m_roadGraphRouter) { + // A* routing LOG(LINFO, ("A* route form", MercatorBounds::ToLatLon(source.segmentPoint), "to", MercatorBounds::ToLatLon(target.segmentPoint))); @@ -533,10 +536,10 @@ bool OsrmRouter::FindSingleRouteDispatcher(FeatureGraphNode const & source, Feat { return false; } - } else { + // OSRM Routing vector mwmRouteGeometry; Route::TTurns mwmTurns; Route::TTimes mwmTimes; diff --git a/routing/osrm_router.hpp b/routing/car_router.hpp similarity index 96% rename from routing/osrm_router.hpp rename to routing/car_router.hpp index a4a96c559c..a9eb4f5956 100644 --- a/routing/osrm_router.hpp +++ b/routing/car_router.hpp @@ -25,13 +25,13 @@ using TCheckedPath = vector; typedef vector TFeatureGraphNodeVec; -class OsrmRouter : public IRouter +class CarRouter : public IRouter { public: typedef vector GeomTurnCandidateT; - OsrmRouter(Index * index, TCountryFileFn const & countryFileFn, - unique_ptr roadGraphRouter); + CarRouter(Index * index, TCountryFileFn const & countryFileFn, + unique_ptr roadGraphRouter); virtual string GetName() const override; diff --git a/routing/cross_mwm_road_graph.hpp b/routing/cross_mwm_road_graph.hpp index e0a59911f7..7687c3246f 100644 --- a/routing/cross_mwm_road_graph.hpp +++ b/routing/cross_mwm_road_graph.hpp @@ -1,7 +1,7 @@ #pragma once +#include "car_router.hpp" #include "osrm_engine.hpp" -#include "osrm_router.hpp" #include "router.hpp" #include "indexer/index.hpp" diff --git a/routing/routing.pro b/routing/routing.pro index 6d676f711c..8eca9f8dd7 100644 --- a/routing/routing.pro +++ b/routing/routing.pro @@ -18,6 +18,7 @@ SOURCES += \ bicycle_directions.cpp \ bicycle_model.cpp \ car_model.cpp \ + car_router.cpp \ cross_mwm_road_graph.cpp \ cross_mwm_router.cpp \ cross_routing_context.cpp \ @@ -30,7 +31,6 @@ SOURCES += \ osrm_engine.cpp \ osrm_helpers.cpp \ osrm_path_segment_factory.cpp \ - osrm_router.cpp \ pedestrian_directions.cpp \ pedestrian_model.cpp \ road_graph.cpp \ @@ -57,6 +57,7 @@ HEADERS += \ bicycle_directions.hpp \ bicycle_model.hpp \ car_model.hpp \ + car_router.hpp \ cross_mwm_road_graph.hpp \ cross_mwm_router.hpp \ cross_routing_context.hpp \ @@ -71,7 +72,6 @@ HEADERS += \ osrm_engine.hpp \ osrm_helpers.hpp \ osrm_path_segment_factory.hpp \ - osrm_router.hpp \ pedestrian_directions.hpp \ pedestrian_model.hpp \ road_graph.hpp \ diff --git a/routing/routing_integration_tests/routing_test_tools.cpp b/routing/routing_integration_tests/routing_test_tools.cpp index c292ef0330..aae10bd28b 100644 --- a/routing/routing_integration_tests/routing_test_tools.cpp +++ b/routing/routing_integration_tests/routing_test_tools.cpp @@ -74,16 +74,16 @@ namespace integration return storage::CountryInfoReader::CreateCountryInfoReader(platform); } - unique_ptr CreateOsrmRouter(Index & index, - storage::CountryInfoGetter const & infoGetter) + unique_ptr CreateCarRouter(Index & index, + storage::CountryInfoGetter const & infoGetter) { auto const countryFileGetter = [&infoGetter](m2::PointD const & pt) { return infoGetter.GetRegionCountryId(pt); }; - unique_ptr osrmRouter(new OsrmRouter(&index, countryFileGetter, - CreateCarAStarBidirectionalRouter(index, countryFileGetter))); - return osrmRouter; + unique_ptr carRouter(new CarRouter(&index, countryFileGetter, + CreateCarAStarBidirectionalRouter(index, countryFileGetter))); + return carRouter; } unique_ptr CreateAStarRouter(Index & index, @@ -105,14 +105,14 @@ namespace integration public: OsrmRouterComponents(vector const & localFiles) : IRouterComponents(localFiles) - , m_osrmRouter(CreateOsrmRouter(m_featuresFetcher->GetIndex(), *m_infoGetter)) + , m_carRouter(CreateCarRouter(m_featuresFetcher->GetIndex(), *m_infoGetter)) { } - IRouter * GetRouter() const override { return m_osrmRouter.get(); } + IRouter * GetRouter() const override { return m_carRouter.get(); } private: - unique_ptr m_osrmRouter; + unique_ptr m_carRouter; }; class PedestrianRouterComponents : public IRouterComponents diff --git a/routing/routing_integration_tests/routing_test_tools.hpp b/routing/routing_integration_tests/routing_test_tools.hpp index 4145b18bce..cefa6b314b 100644 --- a/routing/routing_integration_tests/routing_test_tools.hpp +++ b/routing/routing_integration_tests/routing_test_tools.hpp @@ -1,6 +1,6 @@ #pragma once -#include "routing/osrm_router.hpp" +#include "routing/car_router.hpp" #include "storage/country_info_getter.hpp" diff --git a/routing/routing_tests/osrm_router_test.cpp b/routing/routing_tests/osrm_router_test.cpp index c9ac49a9ae..d706cf78a3 100644 --- a/routing/routing_tests/osrm_router_test.cpp +++ b/routing/routing_tests/osrm_router_test.cpp @@ -1,6 +1,6 @@ #include "testing/testing.hpp" -#include "routing/osrm_router.hpp" +#include "routing/car_router.hpp" #include "indexer/features_offsets_table.hpp" #include "geometry/mercator.hpp"