| 242 | // Returns true iff feature name was indexed as postcode and should be ignored for name indexing. |
| 243 | template <class FnT> |
| 244 | bool 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 | |
| 276 | template <class ContT> |
| 277 | class FeatureInserter |
no test coverage detected