Some Improvements to the Previous Modifications
1. Changed the indent to 2 spaces 2. Moved the instantiations of RoutingOptions member variable of EdgeEstimator to its constructor, so we no longer need to create a new RoutingOptions object before each CalcSegmentWeight() call 3. Added the similar mechanisms to BicycleEstimator and PedestrianEstimator
This commit is contained in:
parent
e685290731
commit
d224a441c5
5 changed files with 30 additions and 8 deletions
|
@ -132,6 +132,8 @@ EdgeEstimator::EdgeEstimator(double maxWeightSpeedKMpH, SpeedKMpH const & offroa
|
|||
|
||||
if (m_offroadSpeedKMpH.m_eta != kNotUsed)
|
||||
CHECK_GREATER_OR_EQUAL(m_maxWeightSpeedMpS, KmphToMps(m_offroadSpeedKMpH.m_eta), ());
|
||||
|
||||
m_avoidRoutingOptions = RoutingOptions();
|
||||
}
|
||||
|
||||
double EdgeEstimator::CalcHeuristic(ms::LatLon const & from, ms::LatLon const & to) const
|
||||
|
@ -212,12 +214,12 @@ double EdgeEstimator::CalcOffroad(ms::LatLon const & from, ms::LatLon const & to
|
|||
|
||||
RoutingOptions EdgeEstimator::GetAvoidRoutingOptions() const
|
||||
{
|
||||
return m_avoidRoutingOptions;
|
||||
return m_avoidRoutingOptions;
|
||||
}
|
||||
|
||||
void EdgeEstimator::SetAvoidRoutingOptions(RoutingOptions avoidRoutingOptions)
|
||||
void EdgeEstimator::SetAvoidRoutingOptions(RoutingOptions::RoadType options)
|
||||
{
|
||||
m_avoidRoutingOptions = avoidRoutingOptions;
|
||||
m_avoidRoutingOptions.SetOptions(options);
|
||||
}
|
||||
|
||||
// PedestrianEstimator -----------------------------------------------------------------------------
|
||||
|
@ -245,7 +247,14 @@ public:
|
|||
double CalcSegmentWeight(Segment const & segment, RoadGeometry const & road,
|
||||
Purpose purpose) const override
|
||||
{
|
||||
return CalcClimbSegment(purpose, segment, road, GetPedestrianClimbPenalty);
|
||||
double result = CalcClimbSegment(purpose, segment, road, GetPedestrianClimbPenalty);
|
||||
|
||||
if (!road.SuitableForOptions(EdgeEstimator::GetAvoidRoutingOptions()))
|
||||
{
|
||||
result += (24 * 60 * 60);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -274,7 +283,14 @@ public:
|
|||
double CalcSegmentWeight(Segment const & segment, RoadGeometry const & road,
|
||||
Purpose purpose) const override
|
||||
{
|
||||
return CalcClimbSegment(purpose, segment, road, GetBicycleClimbPenalty);
|
||||
double result = CalcClimbSegment(purpose, segment, road, GetBicycleClimbPenalty);
|
||||
|
||||
if (!road.SuitableForOptions(EdgeEstimator::GetAvoidRoutingOptions()))
|
||||
{
|
||||
result += (24 * 60 * 60);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
double CalcOffroad(ms::LatLon const & from, ms::LatLon const & to, Purpose purpose) const;
|
||||
|
||||
RoutingOptions GetAvoidRoutingOptions() const;
|
||||
void SetAvoidRoutingOptions(RoutingOptions avoidRoutingOptions);
|
||||
void SetAvoidRoutingOptions(RoutingOptions::RoadType options);
|
||||
|
||||
virtual double CalcSegmentWeight(Segment const & segment, RoadGeometry const & road,
|
||||
Purpose purpose) const = 0;
|
||||
|
|
|
@ -556,7 +556,7 @@ RouteWeight IndexGraph::CalculateEdgeWeight(EdgeEstimator::Purpose purpose, bool
|
|||
auto const & segment = isOutgoing ? to : from;
|
||||
auto const & road = GetRoadGeometry(segment.GetFeatureId());
|
||||
|
||||
m_estimator->SetAvoidRoutingOptions(this->m_avoidRoutingOptions);
|
||||
m_estimator->SetAvoidRoutingOptions(this->m_avoidRoutingOptions.GetOptions());
|
||||
|
||||
auto const weight = RouteWeight(m_estimator->CalcSegmentWeight(segment, road, purpose));
|
||||
auto const penalties = GetPenalties(purpose, isOutgoing ? from : to, isOutgoing ? to : from, prevWeight);
|
||||
|
|
|
@ -28,7 +28,7 @@ RoutingOptions RoutingOptions::LoadCarOptionsFromSettings()
|
|||
{
|
||||
uint32_t mode = 0;
|
||||
if (!settings::Get(kAvoidRoutingOptionSettingsForCar, mode))
|
||||
mode = 2;
|
||||
mode = 4;
|
||||
|
||||
return RoutingOptions(base::checked_cast<RoadType>(mode));
|
||||
}
|
||||
|
@ -55,6 +55,11 @@ bool RoutingOptions::Has(RoutingOptions::Road type) const
|
|||
return (m_options & static_cast<RoadType>(type)) != 0;
|
||||
}
|
||||
|
||||
void RoutingOptions::SetOptions(RoadType options)
|
||||
{
|
||||
m_options = options;
|
||||
}
|
||||
|
||||
// RoutingOptionsClassifier ---------------------------------------------------------------------------
|
||||
|
||||
RoutingOptionsClassifier::RoutingOptionsClassifier()
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
bool Has(Road type) const;
|
||||
|
||||
RoadType GetOptions() const { return m_options; }
|
||||
void SetOptions(RoadType options);
|
||||
|
||||
private:
|
||||
RoadType m_options = 0;
|
||||
|
|
Reference in a new issue