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:
authorMikhail Gorbushin <m.gorbushin@corp.mail.ru>2019-11-23 18:46:44 +0300
committerVladimir Byko-Ianko <bykoianko@gmail.com>2019-11-25 12:55:12 +0300
commit784a263c5323156e3d79063d7d61452b546f4be6 (patch)
treec9ed48500bbf2ebe388159ec90cc6fdb7cb5f85e /routing/index_router.cpp
parent54576a34c568ebeda5c02b8193574cad9cf043c8 (diff)
[routing] Add SetupAlgorithmMode, move block of code to private method
Diffstat (limited to 'routing/index_router.cpp')
-rw-r--r--routing/index_router.cpp53
1 files changed, 30 insertions, 23 deletions
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<Segment> 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<Segment> 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