Files
comaps/indexer/feature_decl.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

81 lines
1.6 KiB
C++

#include "indexer/feature_decl.hpp"
#include "std/boost_container_hash.hpp"
#include <sstream>
namespace feature
{
std::string DebugPrint(GeomType type)
{
return ToString(type);
}
std::string ToString(GeomType type)
{
switch (type)
{
case GeomType::Undefined: return "Undefined";
case GeomType::Point: return "Point";
case GeomType::Line: return "Line";
case GeomType::Area: return "Area";
}
UNREACHABLE();
}
GeomType TypeFromString(std::string type)
{
if (type == "Point")
return GeomType::Point;
else if (type == "Line")
return GeomType::Line;
else if (type == "Area")
return GeomType::Area;
else
return GeomType::Undefined;
}
} // namespace feature
std::string DebugPrint(FeatureID const & id)
{
return "{ " + DebugPrint(id.m_mwmId) + ", " + std::to_string(id.m_index) + " }";
}
std::string FeatureID::GetMwmName() const
{
return IsValid() ? m_mwmId.GetInfo()->GetCountryName() : std::string();
}
int64_t FeatureID::GetMwmVersion() const
{
return IsValid() ? m_mwmId.GetInfo()->GetVersion() : -1;
}
bool FeatureID::IsEqualCountry(base::StringIL const & lst) const
{
if (!IsValid())
return false;
auto const & name = m_mwmId.GetInfo()->GetCountryName();
for (char const * e : lst)
{
if (name.starts_with(e))
return true;
}
return false;
}
bool FeatureID::IsWorld() const
{
return m_mwmId.GetInfo()->GetType() == MwmInfo::MwmTypeT::WORLD;
}
size_t std::hash<FeatureID>::operator()(FeatureID const & fID) const
{
size_t seed = 0;
boost::hash_combine(seed, fID.m_mwmId.GetInfo());
boost::hash_combine(seed, fID.m_index);
return seed;
}