Added ftype::Trunc.

Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
This commit is contained in:
Viktor Govako
2025-07-15 00:00:37 -03:00
committed by Konstantin Pastbin
parent 4e9efa63ff
commit 11ee2b121b
4 changed files with 11 additions and 14 deletions

View File

@@ -95,10 +95,9 @@ string GetWheelchairType(FeatureType & f)
{ {
static const uint32_t wheelchair = classif().GetTypeByPath({"wheelchair"}); static const uint32_t wheelchair = classif().GetTypeByPath({"wheelchair"});
string result; string result;
f.ForEachType([&result](uint32_t type) { f.ForEachType([&result](uint32_t type)
uint32_t truncated = type; {
ftype::TruncValue(truncated, 1); if (ftype::Trunc(type, 1) == wheelchair)
if (truncated == wheelchair)
{ {
string fullName = classif().GetReadableObjectName(type); string fullName = classif().GetReadableObjectName(type);
auto pos = fullName.find("-"); auto pos = fullName.find("-");

View File

@@ -24,6 +24,11 @@ namespace ftype
uint8_t GetValue(uint32_t type, uint8_t level); uint8_t GetValue(uint32_t type, uint8_t level);
void PopValue(uint32_t & type); void PopValue(uint32_t & type);
void TruncValue(uint32_t & type, uint8_t level); void TruncValue(uint32_t & type, uint8_t level);
inline uint32_t Trunc(uint32_t type, uint8_t level)
{
TruncValue(type, level);
return type;
}
uint8_t GetLevel(uint32_t type); uint8_t GetLevel(uint32_t type);
} }

View File

@@ -417,9 +417,7 @@ void FeatureParams::SetRwSubwayType(char const * cityName)
for (size_t i = 0; i < m_types.size(); ++i) for (size_t i = 0; i < m_types.size(); ++i)
{ {
uint32_t t = m_types[i]; if (ftype::Trunc(m_types[i], 2) == src)
ftype::TruncValue(t, 2);
if (t == src)
{ {
m_types[i] = dest; m_types[i] = dest;
break; break;
@@ -492,9 +490,7 @@ uint32_t FeatureParams::FindType(uint32_t comp, uint8_t level) const
{ {
for (uint32_t const type : m_types) for (uint32_t const type : m_types)
{ {
uint32_t t = type; if (ftype::Trunc(type, level) == comp)
ftype::TruncValue(t, level);
if (t == comp)
return type; return type;
} }
return ftype::GetEmptyValue(); return ftype::GetEmptyValue();

View File

@@ -23,10 +23,7 @@ public:
{ {
for (auto level = ftype::GetLevel(t); level; --level) for (auto level = ftype::GetLevel(t); level; --level)
{ {
auto truncatedType = t; auto const it = m_mapping.find(ftype::Trunc(t, level));
ftype::TruncValue(truncatedType, level);
auto const it = m_mapping.find(truncatedType);
if (it != m_mapping.cend()) if (it != m_mapping.cend())
return it; return it;
} }