| 1393 | } // namespace |
| 1394 | |
| 1395 | void GetNameAndType(OsmElement * p, FeatureBuilderParams & params, TypesFilterFnT const & filterType, |
| 1396 | CalculateOriginFnT const & calcOrg) |
| 1397 | { |
| 1398 | // At this point, some preprocessing could've been done to the tags already |
| 1399 | // in TranslatorInterface::Preprocess(), e.g. converting tags according to replaced_tags.txt. |
| 1400 | |
| 1401 | // Stage1: Preprocess tags. |
| 1402 | PreprocessElement(p, calcOrg); |
| 1403 | |
| 1404 | // Stage2: Process feature name on all languages. |
| 1405 | NamesExtractor namesExtractor(params); |
| 1406 | ForEachTag(p, namesExtractor); |
| 1407 | namesExtractor.Finish(); |
| 1408 | |
| 1409 | // Stage3: Process base feature tags. |
| 1410 | std::string houseName, houseNumber, conscriptionHN, streetHN, addrPostcode; |
| 1411 | std::string addrCity, addrSuburb; |
| 1412 | feature::AddressData addr; |
| 1413 | TagProcessor(p).ApplyRules<void(string &, string &)>({ |
| 1414 | {"addr:housenumber", "*", [&houseNumber](string & k, string & v) { houseNumber = std::move(v); }}, |
| 1415 | {"addr:conscriptionnumber", "*", [&conscriptionHN](string & k, string & v) { conscriptionHN = std::move(v); }}, |
| 1416 | {"addr:provisionalnumber", "*", [&conscriptionHN](string & k, string & v) { conscriptionHN = std::move(v); }}, |
| 1417 | {"addr:streetnumber", "*", [&streetHN](string & k, string & v) { streetHN = std::move(v); }}, |
| 1418 | {"contact:housenumber", "*", |
| 1419 | [&houseNumber](string & k, string & v) |
| 1420 | { |
| 1421 | if (houseNumber.empty()) |
| 1422 | houseNumber = std::move(v); |
| 1423 | }}, |
| 1424 | {"addr:housename", "*", [&houseName](string & k, string & v) { houseName = std::move(v); }}, |
| 1425 | {"addr:street", "*", |
| 1426 | [&addr](string & k, string & v) { addr.Set(feature::AddressData::Type::Street, std::move(v)); }}, |
| 1427 | {"contact:street", "*", |
| 1428 | [&addr](string & k, string & v) { addr.SetIfAbsent(feature::AddressData::Type::Street, std::move(v)); }}, |
| 1429 | {"addr:place", "*", |
| 1430 | [&addr](string & k, string & v) { addr.Set(feature::AddressData::Type::Place, std::move(v)); }}, |
| 1431 | {"addr:city", "*", [&addrCity](string & k, string & v) { addrCity = std::move(v); }}, |
| 1432 | {"addr:suburb", "*", [&addrSuburb](string & k, string & v) { addrSuburb = std::move(v); }}, |
| 1433 | {"addr:postcode", "*", [&addrPostcode](string & k, string & v) { addrPostcode = std::move(v); }}, |
| 1434 | {"postal_code", "*", [&addrPostcode](string & k, string & v) { addrPostcode = std::move(v); }}, |
| 1435 | {"contact:postcode", "*", |
| 1436 | [&addrPostcode](string & k, string & v) |
| 1437 | { |
| 1438 | if (addrPostcode.empty()) |
| 1439 | addrPostcode = std::move(v); |
| 1440 | }}, |
| 1441 | {"population", "*", |
| 1442 | [¶ms](string & k, string & v) |
| 1443 | { |
| 1444 | // Get population rank. |
| 1445 | uint64_t const population = generator::osm_element::GetPopulation(v); |
| 1446 | if (population != 0) |
| 1447 | { |
| 1448 | params.rank = feature::PopulationToRank(population); |
| 1449 | // Store raw value as metadata for display on the place page. |
| 1450 | // Must be done here because TagProcessor::Call() clears the tag after this |
| 1451 | // lambda returns, so it never reaches MetadataTagProcessor (Stage 6). |
| 1452 | /// @todo(pastk): don't store unparseable numbers |