Prototype for quantified avoiding options
same as title
This commit is contained in:
parent
23ade377e9
commit
e685290731
4 changed files with 28 additions and 5 deletions
|
@ -4,6 +4,7 @@
|
|||
#include "routing/latlon_with_altitude.hpp"
|
||||
#include "routing/routing_exceptions.hpp"
|
||||
#include "routing/routing_helpers.hpp"
|
||||
#include "routing/routing_options.hpp"
|
||||
#include "routing/traffic_stash.hpp"
|
||||
|
||||
#include "traffic/speed_groups.hpp"
|
||||
|
@ -209,6 +210,16 @@ double EdgeEstimator::CalcOffroad(ms::LatLon const & from, ms::LatLon const & to
|
|||
return TimeBetweenSec(from, to, KmphToMps(offroadSpeedKMpH));
|
||||
}
|
||||
|
||||
RoutingOptions EdgeEstimator::GetAvoidRoutingOptions() const
|
||||
{
|
||||
return m_avoidRoutingOptions;
|
||||
}
|
||||
|
||||
void EdgeEstimator::SetAvoidRoutingOptions(RoutingOptions avoidRoutingOptions)
|
||||
{
|
||||
m_avoidRoutingOptions = avoidRoutingOptions;
|
||||
}
|
||||
|
||||
// PedestrianEstimator -----------------------------------------------------------------------------
|
||||
class PedestrianEstimator final : public EdgeEstimator
|
||||
{
|
||||
|
@ -315,6 +326,11 @@ double CarEstimator::CalcSegmentWeight(Segment const & segment, RoadGeometry con
|
|||
{
|
||||
double result = CalcClimbSegment(purpose, segment, road, GetCarClimbPenalty);
|
||||
|
||||
if (!road.SuitableForOptions(EdgeEstimator::GetAvoidRoutingOptions()))
|
||||
{
|
||||
result += (24 * 60 * 60);
|
||||
}
|
||||
|
||||
if (m_trafficStash)
|
||||
{
|
||||
SpeedGroup const speedGroup = m_trafficStash->GetSpeedGroup(segment);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "routing/routing_options.hpp"
|
||||
#include "routing/segment.hpp"
|
||||
#include "routing/vehicle_mask.hpp"
|
||||
|
||||
|
@ -46,6 +47,9 @@ public:
|
|||
// Estimates time in seconds it takes to go from point |from| to point |to| along direct fake edge.
|
||||
double CalcOffroad(ms::LatLon const & from, ms::LatLon const & to, Purpose purpose) const;
|
||||
|
||||
RoutingOptions GetAvoidRoutingOptions() const;
|
||||
void SetAvoidRoutingOptions(RoutingOptions avoidRoutingOptions);
|
||||
|
||||
virtual double CalcSegmentWeight(Segment const & segment, RoadGeometry const & road,
|
||||
Purpose purpose) const = 0;
|
||||
virtual double GetUTurnPenalty(Purpose purpose) const = 0;
|
||||
|
@ -66,6 +70,7 @@ public:
|
|||
private:
|
||||
double const m_maxWeightSpeedMpS;
|
||||
SpeedKMpH const m_offroadSpeedKMpH;
|
||||
RoutingOptions m_avoidRoutingOptions;
|
||||
|
||||
//DataSource * m_dataSourcePtr;
|
||||
//std::shared_ptr<NumMwmIds> m_numMwmIds;
|
||||
|
|
|
@ -254,8 +254,8 @@ void IndexGraph::GetNeighboringEdges(astar::VertexData<Segment, RouteWeight> con
|
|||
if (!road.IsValid())
|
||||
return;
|
||||
|
||||
if (useRoutingOptions && !road.SuitableForOptions(m_avoidRoutingOptions))
|
||||
return;
|
||||
// if (useRoutingOptions && !road.SuitableForOptions(m_avoidRoutingOptions))
|
||||
// return;
|
||||
|
||||
bool const bidirectional = !road.IsOneWay();
|
||||
auto const & from = fromVertexData.m_vertex;
|
||||
|
@ -282,8 +282,8 @@ void IndexGraph::GetSegmentCandidateForRoadPoint(RoadPoint const & rp, NumMwmId
|
|||
if (!road.IsValid())
|
||||
return;
|
||||
|
||||
if (!road.SuitableForOptions(m_avoidRoutingOptions))
|
||||
return;
|
||||
// if (!road.SuitableForOptions(m_avoidRoutingOptions))
|
||||
// return;
|
||||
|
||||
bool const bidirectional = !road.IsOneWay();
|
||||
auto const pointId = rp.GetPointId();
|
||||
|
@ -556,6 +556,8 @@ 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);
|
||||
|
||||
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 = 0;
|
||||
mode = 2;
|
||||
|
||||
return RoutingOptions(base::checked_cast<RoadType>(mode));
|
||||
}
|
||||
|
|
Reference in a new issue