MCPcopy Create free account
hub / github.com/comaps/comaps / CalcSegmentWeight

Method CalcSegmentWeight

libs/routing/edge_estimator.cpp:792–813  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

790}
791
792double CarEstimator::CalcSegmentWeight(Segment const & segment, RoadGeometry const & road, Purpose purpose) const
793{
794 double result = road.GetDistance(segment.GetSegmentIdx()) / GetSpeedMpS(purpose, segment, road);
795
796 if (m_trafficStash)
797 {
798 SpeedGroup const speedGroup = m_trafficStash->GetSpeedGroup(segment);
799 ASSERT_LESS(speedGroup, SpeedGroup::Count, ());
800 double const trafficFactor = CalcTrafficFactor(speedGroup);
801 result *= trafficFactor;
802 if (speedGroup != SpeedGroup::Unknown && speedGroup != SpeedGroup::G5)
803 {
804 // Current time estimation are too optimistic.
805 // Need more accurate tuning: traffic lights, traffic jams, road models and so on.
806 // Add some penalty to make estimation more realistic.
807 /// @todo Make accurate tuning, remove penalty.
808 result *= 1.8;
809 }
810 }
811
812 return result;
813}
814
815// EdgeEstimator -----------------------------------------------------------------------------------
816// static

Callers

nothing calls this directly

Calls 5

GetSpeedMpSFunction · 0.85
CalcTrafficFactorFunction · 0.85
GetDistanceMethod · 0.45
GetSegmentIdxMethod · 0.45
GetSpeedGroupMethod · 0.45

Tested by

no test coverage detected