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

Function CalcClimbSegment

libs/routing/edge_estimator.cpp:63–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61
62template <class CalcSpeed>
63double CalcClimbSegment(EdgeEstimator::Purpose purpose, Segment const & segment, RoadGeometry const & road,
64 CalcSpeed && calcSpeed)
65{
66 double const distance = road.GetDistance(segment.GetSegmentIdx());
67 double speedMpS = GetSpeedMpS(purpose, segment, road);
68
69 static double constexpr kSmallDistanceM = 1; // we have altitude threshold is 0.5m
70 if (distance > kSmallDistanceM && !IsTransit(road.GetHighwayType()))
71 {
72 LatLonWithAltitude const & from = road.GetJunction(segment.GetPointId(false /* front */));
73 LatLonWithAltitude const & to = road.GetJunction(segment.GetPointId(true /* front */));
74
75 ASSERT(to.GetAltitude() != geometry::kInvalidAltitude && from.GetAltitude() != geometry::kInvalidAltitude, ());
76 auto const altitudeDiff = to.GetAltitude() - from.GetAltitude();
77
78 if (altitudeDiff != 0)
79 {
80 speedMpS = calcSpeed(speedMpS, altitudeDiff / distance, to.GetAltitude());
81 ASSERT_GREATER(speedMpS, 0.0, (segment));
82 }
83 }
84
85 return distance / speedMpS;
86}
87} // namespace
88
89double GetPedestrianClimbPenalty(EdgeEstimator::Purpose purpose, double tangent, geometry::Altitude altitudeM)

Callers 2

CalcSegmentWeightMethod · 0.85
CalcSegmentWeightMethod · 0.85

Calls 8

GetSpeedMpSFunction · 0.85
IsTransitFunction · 0.85
ASSERTFunction · 0.85
GetDistanceMethod · 0.45
GetSegmentIdxMethod · 0.45
GetHighwayTypeMethod · 0.45
GetPointIdMethod · 0.45
GetAltitudeMethod · 0.45

Tested by

no test coverage detected