[generator] Fixed bug with transforming entrance -> address.

Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
This commit is contained in:
Viktor Govako 2021-09-30 12:08:02 +02:00
parent 393a85c50e
commit 1aa26ab8b4
2 changed files with 40 additions and 14 deletions

View file

@ -155,22 +155,45 @@ UNIT_CLASS_TEST(TestWithClassificator, OsmType_Combined)
UNIT_CLASS_TEST(TestWithClassificator, OsmType_Address)
{
Tags const tags = {
{ "addr:conscriptionnumber", "223" },
{ "addr:housenumber", "223/5" },
{ "addr:postcode", "11000" },
{ "addr:street", "Řetězová" },
{ "addr:streetnumber", "5" },
{ "source:addr", "uir_adr" },
{ "uir_adr:ADRESA_KOD", "21717036" }
};
{
Tags const tags = {
{ "addr:conscriptionnumber", "223" },
{ "addr:housenumber", "223/5" },
{ "addr:postcode", "11000" },
{ "addr:street", "Řetězová" },
{ "addr:streetnumber", "5" },
{ "source:addr", "uir_adr" },
{ "uir_adr:ADRESA_KOD", "21717036" }
};
auto const params = GetFeatureBuilderParams(tags);
auto const params = GetFeatureBuilderParams(tags);
TEST_EQUAL(params.m_types.size(), 1, (params));
TEST(params.IsTypeExist(GetType({"building", "address"})), ());
TEST_EQUAL(params.m_types.size(), 1, (params));
TEST(params.IsTypeExist(GetType({"building", "address"})), ());
TEST_EQUAL(params.house.Get(), "223/5", ());
TEST_EQUAL(params.house.Get(), "223/5", ());
}
{
Tags const tags = {
{"addr:city", "Zürich"},
{"addr:housenumber", "41"},
{"addr:postcode", "8050"},
{"addr:street", "Leutschenbachstrasse"},
{"entrance", "main"},
{"survey:date", "2020-12-17"},
{"wheelchair", "no"},
};
auto const params = GetFeatureBuilderParams(tags);
TEST_EQUAL(params.m_types.size(), 2, (params));
TEST(params.IsTypeExist(GetType({"building", "address"})), ());
TEST(params.IsTypeExist(GetType({"wheelchair", "no"})), ());
TEST(!params.IsTypeExist(GetType({"entrance"})), ());
TEST_EQUAL(params.house.Get(), "41", ());
}
}
UNIT_CLASS_TEST(TestWithClassificator, OsmType_PlaceState)

View file

@ -231,6 +231,7 @@ public:
Wlan,
RailwayStation,
SubwayStation,
WheelchairAny,
WheelchairYes,
BarrierGate,
Toll,
@ -265,6 +266,7 @@ public:
{Type::Wlan, {"internet_access", "wlan"}},
{Type::RailwayStation, {"railway", "station"}},
{Type::SubwayStation, {"railway", "station", "subway"}},
{Type::WheelchairAny, {"wheelchair"}},
{Type::WheelchairYes, {"wheelchair", "yes"}},
{Type::BarrierGate, {"barrier", "gate"}},
{Type::Toll, {"hwtag", "toll"}},
@ -717,7 +719,8 @@ void PostprocessElement(OsmElement * p, FeatureBuilderParams & params)
{
// Delete "entrance" type for house number (use it only with refs).
// Add "address" type if we have house number but no valid types.
if (params.PopExactType(types.Get(CachedTypes::Type::Entrance)))
if (params.PopExactType(types.Get(CachedTypes::Type::Entrance)) ||
(params.m_types.size() == 1 && params.IsTypeExist(types.Get(CachedTypes::Type::WheelchairAny), 1)))
{
params.name.Clear();
// If we have address (house name or number), we should assign valid type.