Review fixes.

This commit is contained in:
Vladimir Byko-Ianko 2016-12-05 17:57:36 +03:00
parent 61080424e2
commit 56a37cd83a
7 changed files with 14 additions and 23 deletions

View file

@ -12,7 +12,7 @@ double CalcTrafficFactor(SpeedGroup speedGroup)
{
double const percentage =
0.01 * static_cast<double>(kSpeedGroupThresholdPercentage[static_cast<size_t>(speedGroup)]);
CHECK_GREATER(percentage, 0.0, ("speedGroup:", speedGroup));
CHECK_GREATER(percentage, 0.0, ("Speed group:", speedGroup));
return 1.0 / percentage;
}
} // namespace
@ -32,7 +32,7 @@ inline double TimeBetweenSec(m2::PointD const & from, m2::PointD const & to, dou
class CarEdgeEstimator : public EdgeEstimator
{
public:
CarEdgeEstimator(IVehicleModel const & vehicleModel, traffic::TrafficCache const & getter);
CarEdgeEstimator(IVehicleModel const & vehicleModel, traffic::TrafficCache const & trafficCache);
// EdgeEstimator overrides:
void Start(MwmSet::MwmId const & mwmId) override;
@ -42,20 +42,20 @@ public:
double CalcHeuristic(m2::PointD const & from, m2::PointD const & to) const override;
private:
TrafficCache const & m_trafficGetter;
TrafficCache const & m_trafficCache;
shared_ptr<traffic::TrafficInfo> m_trafficInfo;
double const m_maxSpeedMPS;
};
CarEdgeEstimator::CarEdgeEstimator(IVehicleModel const & vehicleModel,
traffic::TrafficCache const & getter)
: m_trafficGetter(getter), m_maxSpeedMPS(vehicleModel.GetMaxSpeed() * kKMPH2MPS)
traffic::TrafficCache const & trafficCache)
: m_trafficCache(trafficCache), m_maxSpeedMPS(vehicleModel.GetMaxSpeed() * kKMPH2MPS)
{
}
void CarEdgeEstimator::Start(MwmSet::MwmId const & mwmId)
{
m_trafficInfo = m_trafficGetter.GetTrafficInfo(mwmId);
m_trafficInfo = m_trafficCache.GetTrafficInfo(mwmId);
}
void CarEdgeEstimator::Finish()
@ -100,8 +100,8 @@ namespace routing
{
// static
shared_ptr<EdgeEstimator> EdgeEstimator::CreateForCar(IVehicleModel const & vehicleModel,
traffic::TrafficCache const & getter)
traffic::TrafficCache const & trafficCache)
{
return make_shared<CarEdgeEstimator>(vehicleModel, getter);
return make_shared<CarEdgeEstimator>(vehicleModel, trafficCache);
}
} // namespace routing

View file

@ -27,7 +27,7 @@ public:
static shared_ptr<EdgeEstimator> CreateForCar(IVehicleModel const & vehicleModel,
traffic::TrafficCache const & getter);
traffic::TrafficCache const & trafficCache);
};
class EstimatorGuard final

View file

@ -79,14 +79,14 @@ namespace integration
unique_ptr<CarRouter> CreateCarRouter(Index & index,
storage::CountryInfoGetter const & infoGetter,
traffic::TrafficCache const & trafficGetter)
traffic::TrafficCache const & trafficCache)
{
auto const countryFileGetter = [&infoGetter](m2::PointD const & pt) {
return infoGetter.GetRegionCountryId(pt);
};
auto carRouter = make_unique<CarRouter>(index, countryFileGetter,
SingleMwmRouter::CreateCarRouter(index, trafficGetter));
SingleMwmRouter::CreateCarRouter(index, trafficCache));
return carRouter;
}

View file

@ -213,13 +213,13 @@ bool SingleMwmRouter::LoadIndex(MwmSet::MwmId const & mwmId, string const & coun
// static
unique_ptr<SingleMwmRouter> SingleMwmRouter::CreateCarRouter(
Index const & index, traffic::TrafficCache const & getter)
Index const & index, traffic::TrafficCache const & trafficCache)
{
auto vehicleModelFactory = make_shared<CarModelFactory>();
// @TODO Bicycle turn generation engine is used now. It's ok for the time being.
// But later a special car turn generation engine should be implemented.
auto directionsEngine = make_unique<BicycleDirectionsEngine>(index);
auto estimator = EdgeEstimator::CreateForCar(*vehicleModelFactory->GetVehicleModel(), getter);
auto estimator = EdgeEstimator::CreateForCar(*vehicleModelFactory->GetVehicleModel(), trafficCache);
auto router =
make_unique<SingleMwmRouter>("astar-bidirectional-car", index,
move(vehicleModelFactory), estimator, move(directionsEngine));

View file

@ -33,7 +33,7 @@ public:
Route & route);
static unique_ptr<SingleMwmRouter> CreateCarRouter(Index const & index,
traffic::TrafficCache const & getter);
traffic::TrafficCache const & trafficCache);
private:
IRouter::ResultCode DoCalculateRoute(MwmSet::MwmId const & mwmId, m2::PointD const & startPoint,

View file

@ -77,13 +77,6 @@ TrafficInfo::TrafficInfo(MwmSet::MwmId const & mwmId, int64_t currentDataVersion
, m_currentDataVersion(currentDataVersion)
{}
TrafficInfo::TrafficInfo(TrafficInfo && info)
: m_coloring(move(info.m_coloring))
, m_mwmId(info.m_mwmId)
, m_availability(info.m_availability)
, m_currentDataVersion(info.m_currentDataVersion)
{}
// static
TrafficInfo TrafficInfo::BuildForTesting(Coloring && coloring)
{

View file

@ -68,8 +68,6 @@ public:
TrafficInfo(MwmSet::MwmId const & mwmId, int64_t currentDataVersion);
TrafficInfo(TrafficInfo && info);
static TrafficInfo BuildForTesting(Coloring && coloring);
// Fetches the latest traffic data from the server and updates the coloring.