Files
comaps/traffic/speed_groups.cpp
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

38 lines
948 B
C++

#include "traffic/speed_groups.hpp"
#include "base/math.hpp"
namespace traffic
{
uint32_t const kSpeedGroupThresholdPercentage[] = {8, 16, 33, 58, 83, 100, 100, 100};
SpeedGroup GetSpeedGroupByPercentage(double p)
{
p = base::Clamp(p, 0.0, 100.0);
SpeedGroup res = SpeedGroup::Unknown;
for (int i = static_cast<int>(SpeedGroup::Count) - 1; i >= 0; --i)
{
if (p <= kSpeedGroupThresholdPercentage[i])
res = static_cast<SpeedGroup>(i);
}
return res;
}
std::string DebugPrint(SpeedGroup const & group)
{
switch (group)
{
case SpeedGroup::G0: return "G0";
case SpeedGroup::G1: return "G1";
case SpeedGroup::G2: return "G2";
case SpeedGroup::G3: return "G3";
case SpeedGroup::G4: return "G4";
case SpeedGroup::G5: return "G5";
case SpeedGroup::TempBlock: return "TempBlock";
case SpeedGroup::Unknown: return "Unknown";
case SpeedGroup::Count: return "Count";
}
UNREACHABLE();
}
} // namespace traffic