mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-08 05:17:56 +00:00
committed by
Konstantin Pastbin
parent
c9cbb64f12
commit
76ffc99abd
43
libs/search/city_finder.cpp
Normal file
43
libs/search/city_finder.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include "search/city_finder.hpp"
|
||||
|
||||
#include "indexer/feature_decl.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace search
|
||||
{
|
||||
CityFinder::CityFinder(DataSource const & dataSource)
|
||||
: m_unusedBoundaries(dataSource)
|
||||
, m_unusedCache(m_cancellable)
|
||||
, m_finder(dataSource, m_unusedBoundaries, m_unusedCache)
|
||||
{
|
||||
}
|
||||
|
||||
string CityFinder::GetCityName(m2::PointD const & p, int8_t lang)
|
||||
{
|
||||
string_view city;
|
||||
m_finder.GetLocality(p, [&](LocalityItem const & item)
|
||||
{
|
||||
item.GetSpecifiedOrDefaultName(lang, city);
|
||||
});
|
||||
|
||||
// Return string, because m_finder.GetLocality() is not persistent.
|
||||
return std::string(city);
|
||||
}
|
||||
|
||||
string CityFinder::GetCityReadableName(m2::PointD const & p)
|
||||
{
|
||||
string_view city;
|
||||
m_finder.GetLocality(p, [&](LocalityItem const & item) { item.GetReadableName(city); });
|
||||
|
||||
// Return string, because m_finder.GetLocality() is not persistent.
|
||||
return std::string(city);
|
||||
}
|
||||
|
||||
FeatureID CityFinder::GetCityFeatureID(m2::PointD const & p)
|
||||
{
|
||||
FeatureID id;
|
||||
m_finder.GetLocality(p, [&id](LocalityItem const & item) { id = item.m_id; });
|
||||
return id;
|
||||
}
|
||||
} // namespace search
|
||||
Reference in New Issue
Block a user