mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-28 17:03:38 +00:00
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
This commit is contained in:
37
traffic/speed_groups.cpp
Normal file
37
traffic/speed_groups.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user