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

Function InsertPostcodes

generator/search_index_builder.cpp:244–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242// Returns true iff feature name was indexed as postcode and should be ignored for name indexing.
243template <class FnT>
244bool InsertPostcodes(FeatureType & f, FnT && fn)
245{
246 using namespace search;
247
248 // PostBox only, not IsPostPoiChecker?
249 auto const & postBoxChecker = ftypes::IsPostBoxChecker::Instance();
250 auto const postcode = f.GetMetadata(feature::Metadata::FMD_POSTCODE);
251
252 if (!postcode.empty())
253 ForEachNormalizedToken(postcode, fn);
254
255 bool useNameAsPostcode = false;
256 if (postBoxChecker(f))
257 {
258 auto const & names = f.GetNames();
259 if (names.CountLangs() == 1)
260 {
261 std::string_view defaultName;
262 names.GetString(localisation::kDefaultNameIndex, defaultName);
263 if (!defaultName.empty() && LooksLikePostcode(defaultName, false /* isPrefix */))
264 {
265 // In UK it's common practice to set outer postcode as postcode and outer + inner as ref.
266 // We convert ref to name at FeatureBuilder.
267 ForEachNormalizedToken(defaultName, fn);
268 useNameAsPostcode = true;
269 }
270 }
271 }
272
273 return useNameAsPostcode;
274}
275
276template <class ContT>
277class FeatureInserter

Callers 1

operator()Method · 0.85

Calls 7

ForEachNormalizedTokenFunction · 0.85
LooksLikePostcodeFunction · 0.85
CountLangsMethod · 0.80
GetMetadataMethod · 0.45
emptyMethod · 0.45
GetNamesMethod · 0.45
GetStringMethod · 0.45

Tested by

no test coverage detected