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

Method GetMaxspeed

libs/routing/maxspeeds.cpp:20–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20Maxspeed Maxspeeds::GetMaxspeed(uint32_t fid) const
21{
22 // Forward only maxspeeds.
23 if (HasForwardMaxspeed(fid))
24 {
25 auto const r = m_forwardMaxspeedsTable.rank(fid);
26 CHECK_LESS(r, m_forwardMaxspeeds.Size(), ());
27 uint8_t const macro = m_forwardMaxspeeds.Get(r);
28 auto const speed = GetMaxspeedConverter().MacroToSpeed(static_cast<SpeedMacro>(macro));
29 CHECK(speed.IsValid(), ());
30 return {speed.GetUnits(), speed.GetSpeed(), kInvalidSpeed};
31 }
32
33 // Bidirectional maxspeeds.
34 auto const range = std::equal_range(m_bidirectionalMaxspeeds.cbegin(), m_bidirectionalMaxspeeds.cend(), fid,
35 FeatureMaxspeed::Less());
36
37 if (range.second == range.first)
38 return Maxspeed(); // No maxspeed for |fid| is set. Returns an invalid Maxspeed instance.
39
40 CHECK_EQUAL(range.second - range.first, 1, ());
41 return range.first->GetMaxspeed();
42}
43
44MaxspeedType Maxspeeds::GetDefaultSpeed(bool inCity, HighwayType hwType) const
45{

Callers 7

GetRoadInfoMethod · 0.80
TestMaxspeedsSectionFunction · 0.80
ShowInfoPopupMethod · 0.80
GetSavedMaxspeedMethod · 0.80
LoadMethod · 0.80
DebugPrintFunction · 0.80

Calls 12

equal_rangeFunction · 0.85
MaxspeedClass · 0.85
MacroToSpeedMethod · 0.80
LessClass · 0.50
rankMethod · 0.45
SizeMethod · 0.45
GetMethod · 0.45
IsValidMethod · 0.45
GetUnitsMethod · 0.45
GetSpeedMethod · 0.45
cbeginMethod · 0.45
cendMethod · 0.45

Tested by 2

TestMaxspeedsSectionFunction · 0.64