mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 13:23:59 +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:
80
indexer/feature_decl.cpp
Normal file
80
indexer/feature_decl.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user