[generator] Process address "contact:housenumber/street/postcode" tags.

Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
This commit is contained in:
Viktor Govako 2023-05-03 13:48:58 -03:00
parent 28bedbd3e5
commit f6a3ac756c
2 changed files with 54 additions and 7 deletions

View file

@ -262,6 +262,31 @@ UNIT_CLASS_TEST(TestWithClassificator, OsmType_Address)
TEST(params.GetStreet().empty(), ());
TEST_EQUAL(params.GetPostcode(), "LV-5695", ());
}
{
Tags const tags = {
{"building", "yes"},
{"contact:city", "Paris"},
{"contact:housenumber", "13"},
{"contact:phone", "+33 1 44 77 60 60"},
{"contact:postcode", "75001"},
{"contact:street", "Place Vendôme"},
{"contact:website", "https://www.justice.gouv.fr/"},
{"government", "ministry"},
{"historic", "manor"},
{"layer", "1"},
{"name", "Ministère de la Justice"},
{"office", "government"},
{"wikidata", "Q3145763"},
};
auto const params = GetFeatureBuilderParams(tags);
TEST_EQUAL(params.m_types.size(), 3, (params));
TEST_EQUAL(params.house.Get(), "13", ());
TEST_EQUAL(params.GetStreet(), "Place Vendôme", ());
TEST_EQUAL(params.GetPostcode(), "75001", ());
}
}
UNIT_CLASS_TEST(TestWithClassificator, OsmType_PlaceState)

View file

@ -1069,7 +1069,7 @@ void GetNameAndType(OsmElement * p, FeatureBuilderParams & params,
namesExtractor.Finish();
// Stage3: Process base feature tags.
std::string houseName, houseNumber, addrPostcode;
std::string houseName, houseNumber, addrStreet, addrPostcode;
TagProcessor(p).ApplyRules<void(string &, string &)>(
{
{"addr:housenumber", "*",
@ -1078,18 +1078,32 @@ void GetNameAndType(OsmElement * p, FeatureBuilderParams & params,
k.clear();
v.clear();
}},
{"contact:housenumber", "*", [&houseNumber](string & k, string & v)
{
if (houseNumber.empty())
houseNumber = std::move(v);
k.clear();
v.clear();
}},
{"addr:housename", "*",
[&houseName](string & k, string & v) {
houseName = std::move(v);
k.clear();
v.clear();
}},
{"addr:street", "*",
[&params](string & k, string & v) {
params.SetStreet(std::move(v));
k.clear();
v.clear();
}},
{"addr:street", "*", [&addrStreet](string & k, string & v)
{
addrStreet = std::move(v);
k.clear();
v.clear();
}},
{"contact:street", "*", [&addrStreet](string & k, string & v)
{
if (addrStreet.empty())
addrStreet = std::move(v);
k.clear();
v.clear();
}},
{"addr:postcode", "*", [&addrPostcode](string & k, string & v)
{
addrPostcode = std::move(v);
@ -1102,6 +1116,13 @@ void GetNameAndType(OsmElement * p, FeatureBuilderParams & params,
k.clear();
v.clear();
}},
{"contact:postcode", "*", [&addrPostcode](string & k, string & v)
{
if (addrPostcode.empty())
addrPostcode = std::move(v);
k.clear();
v.clear();
}},
{"population", "*",
[&params](string & k, string & v) {
// Get population rank.
@ -1129,6 +1150,7 @@ void GetNameAndType(OsmElement * p, FeatureBuilderParams & params,
}},
});
params.SetStreet(std::move(addrStreet));
params.SetPostcode(addrPostcode);
params.SetHouseNumberAndHouseName(std::move(houseNumber), std::move(houseName));