diff --git a/generator/generator_tests/osm_type_test.cpp b/generator/generator_tests/osm_type_test.cpp index 2ed156cd16..eef30ee381 100644 --- a/generator/generator_tests/osm_type_test.cpp +++ b/generator/generator_tests/osm_type_test.cpp @@ -185,6 +185,7 @@ UNIT_CLASS_TEST(TestWithClassificator, OsmType_Combined) UNIT_CLASS_TEST(TestWithClassificator, OsmType_Address) { + uint32_t const addrType = GetType({"building", "address"}); { // Single house number tag is transformed into address type. Tags const tags = { {"addr:housenumber", "42"} }; @@ -192,7 +193,7 @@ UNIT_CLASS_TEST(TestWithClassificator, OsmType_Address) auto const params = GetFeatureBuilderParams(tags); TEST_EQUAL(params.m_types.size(), 1, (params)); - TEST(params.IsTypeExist(GetType({"building", "address"})), ()); + TEST(params.IsTypeExist(addrType), ()); TEST_EQUAL(params.house.Get(), "42", ()); } @@ -213,7 +214,7 @@ UNIT_CLASS_TEST(TestWithClassificator, OsmType_Address) auto const params = GetFeatureBuilderParams(tags); TEST_EQUAL(params.m_types.size(), 1, (params)); - TEST(params.IsTypeExist(GetType({"building", "address"})), ()); + TEST(params.IsTypeExist(addrType), ()); TEST_EQUAL(params.house.Get(), "223/5", ()); TEST_EQUAL(params.GetAddressData().Get(AddrType::Street), "Řetězová", ()); @@ -226,17 +227,19 @@ UNIT_CLASS_TEST(TestWithClassificator, OsmType_Address) {"addr:housenumber", "41"}, {"addr:postcode", "8050"}, {"addr:street", "Leutschenbachstrasse"}, - {"entrance", "home"}, + {"entrance", "main"}, {"survey:date", "2020-12-17"}, {"wheelchair", "no"}, + {"internet_access", "wlan"}, }; auto const params = GetFeatureBuilderParams(tags); - TEST_EQUAL(params.m_types.size(), 2, (params)); - TEST(params.IsTypeExist(GetType({"building", "address"})), ()); + TEST_EQUAL(params.m_types.size(), 4, (params)); + TEST(params.IsTypeExist(addrType), ()); + TEST(params.IsTypeExist(GetType({"entrance", "main"})), ()); TEST(params.IsTypeExist(GetType({"wheelchair", "no"})), ()); - TEST(!params.IsTypeExist(GetType({"entrance"})), ()); + TEST(params.IsTypeExist(GetType({"internet_access", "wlan"})), ()); TEST_EQUAL(params.house.Get(), "41", ()); TEST_EQUAL(params.GetAddressData().Get(AddrType::Street), "Leutschenbachstrasse", ()); diff --git a/generator/osm2type.cpp b/generator/osm2type.cpp index 8cd90dc43d..2177fd6dd2 100644 --- a/generator/osm2type.cpp +++ b/generator/osm2type.cpp @@ -228,6 +228,7 @@ public: HasParts, NoCar, YesCar, + InternetAny, Wlan, RailwayStation, SubwayStation, @@ -263,6 +264,7 @@ public: {Type::HasParts, {"building", "has_parts"}}, {Type::NoCar, {"hwtag", "nocar"}}, {Type::YesCar, {"hwtag", "yescar"}}, + {Type::InternetAny, {"internet_access"}}, {Type::Wlan, {"internet_access", "wlan"}}, {Type::RailwayStation, {"railway", "station"}}, {Type::SubwayStation, {"railway", "station", "subway"}}, @@ -725,15 +727,28 @@ void PostprocessElement(OsmElement * p, FeatureBuilderParams & params) if (!params.house.IsEmpty()) { - // 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)) || - (params.m_types.size() == 1 && params.IsTypeExist(types.Get(CachedTypes::Type::WheelchairAny), 1))) + // Add "building-address" type if we have house number, but no "suitable" (building, POI, etc) types. + // A lot in Czech, Italy or others, with individual address points (house numbers). + bool hasSuitableType = false; + for (uint32_t t : params.m_types) + { + /// @todo Make a function like HaveAddressLikeType ? + ftype::TruncValue(t, 1); + if (t != types.Get(CachedTypes::Type::Entrance) && + t != types.Get(CachedTypes::Type::WheelchairAny) && + t != types.Get(CachedTypes::Type::InternetAny)) + { + hasSuitableType = true; + break; + } + } + + if (!hasSuitableType) { - params.name.Clear(); - // If we have address (house name or number), we should assign valid type. - // There are a lot of features like this in the Czech Republic. params.AddType(types.Get(CachedTypes::Type::Address)); + + if (!params.name.IsEmpty() || !params.ref.empty()) + LOG(LWARNING, ("Address with name or ref:", GetGeoObjectId(*p), params.name, params.ref)); } }