MCPcopy Create free account
hub / github.com/comaps/comaps / FeatureInserter

Class FeatureInserter

generator/search_index_builder.cpp:277–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

275
276template <class ContT>
277class FeatureInserter
278{
279public:
280 FeatureInserter(SynonymsHolder * synonyms, ContT & keyValuePairs, CategoriesHolder const & catHolder,
281 std::pair<int, int> const & scales)
282 : m_synonyms(synonyms)
283 , m_categories(catHolder)
284 , m_scales(scales)
285 , m_inserter(keyValuePairs)
286 {}
287
288 void operator()(FeatureType & f, uint32_t index)
289 {
290 feature::TypesHolder types(f);
291
292 if (m_skipIndex.SkipAlways(types))
293 return;
294 if (m_skipIndex.SkipSpecialNames(types, f.GetName(localisation::kDefaultNameIndex)))
295 return;
296
297 SynonymsHolder const * synonyms = nullptr;
298 if (m_synonyms)
299 {
300 // Insert synonyms only for countries and states (maybe will add cities in future).
301 if (SynonymsHolder::CanApply(types))
302 synonyms = m_synonyms;
303 }
304
305 bool const hasStreetType = ftypes::IsStreetOrSquareChecker::Instance()(types);
306
307 // Init inserter with Feature's index.
308 m_inserter.SetFeature(index, synonyms, hasStreetType);
309
310 bool const useNameAsPostcode =
311 InsertPostcodes(f, [this](auto const & token) { m_inserter.AddToken(search::kPostcodesLang, token); });
312
313 if (!useNameAsPostcode)
314 {
315 m_inserter.m_statsEnabled = true;
316 f.ForEachName(m_inserter);
317 m_inserter.m_statsEnabled = false;
318 }
319
320 // Road number.
321 if (hasStreetType)
322 for (auto const & shield : ftypes::GetRoadShieldsNames(f))
323 m_inserter(localisation::kDefaultNameIndex, shield);
324
325 if (ftypes::IsAirportChecker::Instance()(types))
326 {
327 auto const iata = f.GetMetadata(feature::Metadata::FMD_AIRPORT_IATA);
328 if (!iata.empty())
329 m_inserter(localisation::kDefaultNameIndex, iata);
330 }
331
332 // Index operator to support "Sberbank ATM" for objects with amenity=atm and operator=Sberbank.
333 auto const op = f.GetMetadata(feature::Metadata::FMD_OPERATOR);
334 if (!op.empty())

Callers 1

AddFeatureNameIndexPairsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected