forked from organicmaps/organicmaps
Renaming osrm router to car router.
This commit is contained in:
parent
8cb081727d
commit
f4da573250
8 changed files with 51 additions and 48 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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> roadGraphRouter)
|
||||
CarRouter::CarRouter(Index * index, TCountryFileFn const & countryFileFn,
|
||||
unique_ptr<RoadGraphRouter> 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<Junction> mwmRouteGeometry;
|
||||
Route::TTurns mwmTurns;
|
||||
Route::TTimes mwmTimes;
|
|
@ -25,13 +25,13 @@ using TCheckedPath = vector<RoutePathCross>;
|
|||
|
||||
typedef vector<FeatureGraphNode> TFeatureGraphNodeVec;
|
||||
|
||||
class OsrmRouter : public IRouter
|
||||
class CarRouter : public IRouter
|
||||
{
|
||||
public:
|
||||
typedef vector<double> GeomTurnCandidateT;
|
||||
|
||||
OsrmRouter(Index * index, TCountryFileFn const & countryFileFn,
|
||||
unique_ptr<RoadGraphRouter> roadGraphRouter);
|
||||
CarRouter(Index * index, TCountryFileFn const & countryFileFn,
|
||||
unique_ptr<RoadGraphRouter> roadGraphRouter);
|
||||
|
||||
virtual string GetName() const override;
|
||||
|
|
@ -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"
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -74,16 +74,16 @@ namespace integration
|
|||
return storage::CountryInfoReader::CreateCountryInfoReader(platform);
|
||||
}
|
||||
|
||||
unique_ptr<OsrmRouter> CreateOsrmRouter(Index & index,
|
||||
storage::CountryInfoGetter const & infoGetter)
|
||||
unique_ptr<CarRouter> CreateCarRouter(Index & index,
|
||||
storage::CountryInfoGetter const & infoGetter)
|
||||
{
|
||||
auto const countryFileGetter = [&infoGetter](m2::PointD const & pt)
|
||||
{
|
||||
return infoGetter.GetRegionCountryId(pt);
|
||||
};
|
||||
unique_ptr<OsrmRouter> osrmRouter(new OsrmRouter(&index, countryFileGetter,
|
||||
CreateCarAStarBidirectionalRouter(index, countryFileGetter)));
|
||||
return osrmRouter;
|
||||
unique_ptr<CarRouter> carRouter(new CarRouter(&index, countryFileGetter,
|
||||
CreateCarAStarBidirectionalRouter(index, countryFileGetter)));
|
||||
return carRouter;
|
||||
}
|
||||
|
||||
unique_ptr<IRouter> CreateAStarRouter(Index & index,
|
||||
|
@ -105,14 +105,14 @@ namespace integration
|
|||
public:
|
||||
OsrmRouterComponents(vector<LocalCountryFile> 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<OsrmRouter> m_osrmRouter;
|
||||
unique_ptr<CarRouter> m_carRouter;
|
||||
};
|
||||
|
||||
class PedestrianRouterComponents : public IRouterComponents
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "routing/osrm_router.hpp"
|
||||
#include "routing/car_router.hpp"
|
||||
|
||||
#include "storage/country_info_getter.hpp"
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Add table
Reference in a new issue