| 18 | } |
| 19 | |
| 20 | Maxspeed 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 | |
| 44 | MaxspeedType Maxspeeds::GetDefaultSpeed(bool inCity, HighwayType hwType) const |
| 45 | { |