mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 13:23:59 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -46,16 +46,12 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace indexer
|
||||
{
|
||||
using namespace strings;
|
||||
using namespace search;
|
||||
|
||||
SynonymsHolder::SynonymsHolder()
|
||||
: SynonymsHolder(base::JoinPath(GetPlatform().ResourcesDir(), "synonyms.txt"))
|
||||
{
|
||||
}
|
||||
SynonymsHolder::SynonymsHolder() : SynonymsHolder(base::JoinPath(GetPlatform().ResourcesDir(), "synonyms.txt")) {}
|
||||
|
||||
SynonymsHolder::SynonymsHolder(std::string const & fPath)
|
||||
{
|
||||
@@ -130,11 +126,7 @@ class FeatureNameInserter
|
||||
base::TopStatsCounter<std::string> m_stats;
|
||||
|
||||
public:
|
||||
explicit FeatureNameInserter(ContT & keyValuePairs)
|
||||
: m_suffixes(GetDACHStreets())
|
||||
, m_keyValuePairs(keyValuePairs)
|
||||
{
|
||||
}
|
||||
explicit FeatureNameInserter(ContT & keyValuePairs) : m_suffixes(GetDACHStreets()), m_keyValuePairs(keyValuePairs) {}
|
||||
~FeatureNameInserter()
|
||||
{
|
||||
LOG(LINFO, ("Top street's name tokens:"));
|
||||
@@ -202,10 +194,8 @@ public:
|
||||
if (m_synonyms)
|
||||
{
|
||||
/// @todo Avoid creating temporary std::string.
|
||||
m_synonyms->ForEach(std::string(name), [&](std::string const & utf8str)
|
||||
{
|
||||
tokens.push_back(NormalizeAndSimplifyString(utf8str));
|
||||
});
|
||||
m_synonyms->ForEach(std::string(name),
|
||||
[&](std::string const & utf8str) { tokens.push_back(NormalizeAndSimplifyString(utf8str)); });
|
||||
}
|
||||
|
||||
static_assert(kMaxNumTokens > 0);
|
||||
@@ -218,10 +208,8 @@ public:
|
||||
|
||||
if (m_hasStreetType)
|
||||
{
|
||||
StreetTokensFilter filter([this, lang](UniString const & token, size_t)
|
||||
{
|
||||
AddToken(lang, token);
|
||||
}, false /* withMisprints */);
|
||||
StreetTokensFilter filter([this, lang](UniString const & token, size_t) { AddToken(lang, token); },
|
||||
false /* withMisprints */);
|
||||
|
||||
for (auto const & token : tokens)
|
||||
{
|
||||
@@ -250,7 +238,8 @@ private:
|
||||
};
|
||||
|
||||
// Returns true iff feature name was indexed as postcode and should be ignored for name indexing.
|
||||
template <class FnT> bool InsertPostcodes(FeatureType & f, FnT && fn)
|
||||
template <class FnT>
|
||||
bool InsertPostcodes(FeatureType & f, FnT && fn)
|
||||
{
|
||||
using namespace search;
|
||||
|
||||
@@ -286,14 +275,13 @@ template <class ContT>
|
||||
class FeatureInserter
|
||||
{
|
||||
public:
|
||||
FeatureInserter(SynonymsHolder * synonyms, ContT & keyValuePairs,
|
||||
CategoriesHolder const & catHolder, std::pair<int, int> const & scales)
|
||||
FeatureInserter(SynonymsHolder * synonyms, ContT & keyValuePairs, CategoriesHolder const & catHolder,
|
||||
std::pair<int, int> const & scales)
|
||||
: m_synonyms(synonyms)
|
||||
, m_categories(catHolder)
|
||||
, m_scales(scales)
|
||||
, m_inserter(keyValuePairs)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void operator()(FeatureType & f, uint32_t index)
|
||||
{
|
||||
@@ -317,10 +305,8 @@ public:
|
||||
// Init inserter with Feature's index.
|
||||
m_inserter.SetFeature(index, synonyms, hasStreetType);
|
||||
|
||||
bool const useNameAsPostcode = InsertPostcodes(f, [this](auto const & token)
|
||||
{
|
||||
m_inserter.AddToken(search::kPostcodesLang, token);
|
||||
});
|
||||
bool const useNameAsPostcode =
|
||||
InsertPostcodes(f, [this](auto const & token) { m_inserter.AddToken(search::kPostcodesLang, token); });
|
||||
|
||||
if (!useNameAsPostcode)
|
||||
{
|
||||
@@ -331,10 +317,8 @@ public:
|
||||
|
||||
// Road number.
|
||||
if (hasStreetType)
|
||||
{
|
||||
for (auto const & shield : ftypes::GetRoadShieldsNames(f))
|
||||
m_inserter(StringUtf8Multilang::kDefaultCode, shield);
|
||||
}
|
||||
|
||||
if (ftypes::IsAirportChecker::Instance()(types))
|
||||
{
|
||||
@@ -351,10 +335,8 @@ public:
|
||||
auto const brand = f.GetMetadata(feature::Metadata::FMD_BRAND);
|
||||
if (!brand.empty())
|
||||
{
|
||||
ForEachLocalizedBrands(brand, [this](BrandsHolder::Brand::Name const & name)
|
||||
{
|
||||
m_inserter(name.m_locale, name.m_name);
|
||||
});
|
||||
ForEachLocalizedBrands(
|
||||
brand, [this](BrandsHolder::Brand::Name const & name) { m_inserter(name.m_locale, name.m_name); });
|
||||
}
|
||||
|
||||
// Check for empty name just before categories indexing. After postcodes, and other meta ..
|
||||
@@ -365,9 +347,7 @@ public:
|
||||
|
||||
Classificator const & c = classif();
|
||||
GetCategoryTypes(m_categories, m_scales, types, [this, &c](uint32_t t)
|
||||
{
|
||||
m_inserter.AddToken(search::kCategoriesLang, search::FeatureTypeToString(c.GetIndexForType(t)));
|
||||
});
|
||||
{ m_inserter.AddToken(search::kCategoriesLang, search::FeatureTypeToString(c.GetIndexForType(t))); });
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -381,8 +361,7 @@ private:
|
||||
};
|
||||
|
||||
template <class ContT>
|
||||
void AddFeatureNameIndexPairs(FeaturesVectorTest const & features,
|
||||
CategoriesHolder const & categoriesHolder,
|
||||
void AddFeatureNameIndexPairs(FeaturesVectorTest const & features, CategoriesHolder const & categoriesHolder,
|
||||
ContT & keyValuePairs)
|
||||
{
|
||||
feature::DataHeader const & header = features.GetHeader();
|
||||
@@ -391,7 +370,8 @@ void AddFeatureNameIndexPairs(FeaturesVectorTest const & features,
|
||||
if (header.GetType() == feature::DataHeader::MapType::World)
|
||||
synonyms = std::make_unique<SynonymsHolder>();
|
||||
|
||||
features.GetVector().ForEach(FeatureInserter(synonyms.get(), keyValuePairs, categoriesHolder, header.GetScaleRange()));
|
||||
features.GetVector().ForEach(
|
||||
FeatureInserter(synonyms.get(), keyValuePairs, categoriesHolder, header.GetScaleRange()));
|
||||
}
|
||||
|
||||
void ReadAddressData(std::string const & filename, std::vector<feature::AddressData> & addrs)
|
||||
@@ -406,8 +386,7 @@ void ReadAddressData(std::string const & filename, std::vector<feature::AddressD
|
||||
}
|
||||
|
||||
template <class ObjT, class GetKeyFnT>
|
||||
std::optional<uint32_t> MatchObjectByName(std::string_view keyName, std::vector<ObjT> const & objs,
|
||||
GetKeyFnT && getKey)
|
||||
std::optional<uint32_t> MatchObjectByName(std::string_view keyName, std::vector<ObjT> const & objs, GetKeyFnT && getKey)
|
||||
{
|
||||
size_t constexpr kSimilarityThresholdPercent = 10;
|
||||
|
||||
@@ -458,8 +437,8 @@ std::optional<uint32_t> MatchObjectByName(std::string_view keyName, std::vector<
|
||||
return {};
|
||||
}
|
||||
|
||||
void BuildAddressTable(FilesContainerR & container, std::string const & addressDataFile,
|
||||
Writer & streetsWriter, Writer & placesWriter, uint32_t threadsCount)
|
||||
void BuildAddressTable(FilesContainerR & container, std::string const & addressDataFile, Writer & streetsWriter,
|
||||
Writer & placesWriter, uint32_t threadsCount)
|
||||
{
|
||||
std::vector<feature::AddressData> addrs;
|
||||
ReadAddressData(addressDataFile, addrs);
|
||||
@@ -470,8 +449,7 @@ void BuildAddressTable(FilesContainerR & container, std::string const & addressD
|
||||
FrozenDataSource dataSource;
|
||||
MwmSet::MwmId mwmId;
|
||||
{
|
||||
auto const regResult =
|
||||
dataSource.RegisterMap(platform::LocalCountryFile::MakeTemporary(container.GetFileName()));
|
||||
auto const regResult = dataSource.RegisterMap(platform::LocalCountryFile::MakeTemporary(container.GetFileName()));
|
||||
ASSERT_EQUAL(regResult.second, MwmSet::RegResult::Success, ());
|
||||
mwmId = regResult.first;
|
||||
}
|
||||
@@ -514,26 +492,19 @@ void BuildAddressTable(FilesContainerR & container, std::string const & addressD
|
||||
{
|
||||
auto const streets = search::ReverseGeocoder::GetNearbyStreets(*contexts[threadIdx], center, kStreetRadiusM);
|
||||
streetId = MatchObjectByName(street, streets, [](std::string_view name)
|
||||
{
|
||||
return search::GetStreetNameAsKey(name, false /* ignoreStreetSynonyms */);
|
||||
});
|
||||
{ return search::GetStreetNameAsKey(name, false /* ignoreStreetSynonyms */); });
|
||||
|
||||
if (!streetId)
|
||||
{
|
||||
streetId = MatchObjectByName(street, streets, [](std::string_view name)
|
||||
{
|
||||
return search::GetStreetNameAsKey(name, true /* ignoreStreetSynonyms */);
|
||||
});
|
||||
{ return search::GetStreetNameAsKey(name, true /* ignoreStreetSynonyms */); });
|
||||
}
|
||||
}
|
||||
|
||||
if (!place.empty())
|
||||
{
|
||||
auto const places = search::ReverseGeocoder::GetNearbyPlaces(*contexts[threadIdx], center, kPlaceRadiusM);
|
||||
placeId = MatchObjectByName(place, places, [](std::string_view name)
|
||||
{
|
||||
return strings::MakeUniString(name);
|
||||
});
|
||||
placeId = MatchObjectByName(place, places, [](std::string_view name) { return strings::MakeUniString(name); });
|
||||
}
|
||||
|
||||
if (streetId || placeId)
|
||||
@@ -589,11 +560,10 @@ void BuildAddressTable(FilesContainerR & container, std::string const & addressD
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
void BuildSearchIndex(FilesContainerR & container, Writer & indexWriter);
|
||||
|
||||
bool BuildSearchIndexFromDataFile(std::string const & country, feature::GenerateInfo const & info,
|
||||
bool forceRebuild, uint32_t threadsCount)
|
||||
bool BuildSearchIndexFromDataFile(std::string const & country, feature::GenerateInfo const & info, bool forceRebuild,
|
||||
uint32_t threadsCount)
|
||||
{
|
||||
Platform & platform = GetPlatform();
|
||||
|
||||
@@ -693,8 +663,8 @@ void BuildSearchIndex(FilesContainerR & container, Writer & indexWriter)
|
||||
std::sort(searchIndexKeyValuePairs.begin(), searchIndexKeyValuePairs.end());
|
||||
LOG(LINFO, ("End sorting strings:", timer.ElapsedSeconds()));
|
||||
|
||||
trie::Build<Writer, Key, ValueList<Value>, SingleValueSerializer<Value>>(
|
||||
indexWriter, serializer, searchIndexKeyValuePairs);
|
||||
trie::Build<Writer, Key, ValueList<Value>, SingleValueSerializer<Value>>(indexWriter, serializer,
|
||||
searchIndexKeyValuePairs);
|
||||
|
||||
LOG(LINFO, ("End building search index, elapsed seconds:", timer.ElapsedSeconds()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user