diff --git a/routing/index_router.cpp b/routing/index_router.cpp index 6ee317a35f..ae794594d8 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -66,6 +66,7 @@ uint32_t constexpr kVisitPeriodForLeaps = 10; uint32_t constexpr kVisitPeriod = 40; double constexpr kLeapsStageContribution = 0.15; +double constexpr kAlmostZeroContribution = 1e-7; // If user left the route within this range(meters), adjust the route. Else full rebuild. double constexpr kAdjustRangeM = 5000.0; @@ -450,10 +451,12 @@ RouterResultCode IndexRouter::DoCalculateRoute(Checkpoints const & checkpoints, isStartSegmentStrictForward, *graph); vector subroute; - static double constexpr kEpsAlmostZero = 1e-7; - double const contributionCoef = - !base::AlmostEqualAbs(checkpointsLength, 0.0, kEpsAlmostZero) ? mercator::DistanceOnEarth(startCheckpoint, finishCheckpoint) / checkpointsLength : - kEpsAlmostZero; + double contributionCoef = kAlmostZeroContribution; + if (!base::AlmostEqualAbs(checkpointsLength, 0.0, 1e-5)) + { + contributionCoef = + mercator::DistanceOnEarth(startCheckpoint, finishCheckpoint) / checkpointsLength; + } AStarSubProgress subProgress(startCheckpoint, finishCheckpoint, contributionCoef); progress.AppendSubProgress(subProgress); @@ -546,25 +549,7 @@ RouterResultCode IndexRouter::CalculateSubroute(Checkpoints const & checkpoints, { subroute.clear(); - // We use leaps for cars only. Other vehicle types do not have weights in their cross-mwm sections. - switch (m_vehicleType) - { - case VehicleType::Pedestrian: - case VehicleType::Bicycle: - starter.GetGraph().SetMode(WorldGraphMode::Joints); - break; - case VehicleType::Transit: - starter.GetGraph().SetMode(WorldGraphMode::NoLeaps); - break; - case VehicleType::Car: - starter.GetGraph().SetMode(AreMwmsNear(starter) ? WorldGraphMode::Joints - : WorldGraphMode::LeapsOnly); - break; - case VehicleType::Count: - CHECK(false, ("Unknown vehicle type:", m_vehicleType)); - break; - } - + SetupAlgorithmMode(starter); LOG(LINFO, ("Routing in mode:", starter.GetGraph().GetMode())); auto checkLength = [&starter](RouteWeight const & weight) { return starter.CheckLength(weight); }; @@ -1433,4 +1418,26 @@ void IndexRouter::FillSpeedCamProhibitedMwms(vector const & segments, speedCamProhibitedMwms.emplace_back(country); } } + +void IndexRouter::SetupAlgorithmMode(IndexGraphStarter & starter) +{ + // We use leaps for cars only. Other vehicle types do not have weights in their cross-mwm sections. + switch (m_vehicleType) + { + case VehicleType::Pedestrian: + case VehicleType::Bicycle: + starter.GetGraph().SetMode(WorldGraphMode::Joints); + break; + case VehicleType::Transit: + starter.GetGraph().SetMode(WorldGraphMode::NoLeaps); + break; + case VehicleType::Car: + starter.GetGraph().SetMode(AreMwmsNear(starter) ? WorldGraphMode::Joints + : WorldGraphMode::LeapsOnly); + break; + case VehicleType::Count: + CHECK(false, ("Unknown vehicle type:", m_vehicleType)); + break; + } +} } // namespace routing diff --git a/routing/index_router.hpp b/routing/index_router.hpp index 83d6c459d2..b002383986 100644 --- a/routing/index_router.hpp +++ b/routing/index_router.hpp @@ -194,6 +194,8 @@ private: mwmIds, ConvertResult(algorithm.FindPathBidirectional(params, routingResult))); } + void SetupAlgorithmMode(IndexGraphStarter & starter); + VehicleType m_vehicleType; bool m_loadAltitudes; std::string const m_name;