diff --git a/data/classificator.txt b/data/classificator.txt index 91e5028e62..e88b1024c1 100644 --- a/data/classificator.txt +++ b/data/classificator.txt @@ -334,6 +334,7 @@ world + nofoot - oneway - private - + yesfoot - {} internet_access + wlan - diff --git a/data/mapcss-mapping.csv b/data/mapcss-mapping.csv index 1558a73b02..93eda075a4 100644 --- a/data/mapcss-mapping.csv +++ b/data/mapcss-mapping.csv @@ -1004,3 +1004,4 @@ place|city|capital|8;[place=city][capital=8];;name;int_name;1003; place|city|capital|9;[place=city][capital=9];;name;int_name;1004; place|city|capital|10;[place=city][capital=10];;name;int_name;1005; place|city|capital|11;[place=city][capital=11];;name;int_name;1006; +hwtag|yesfoot;[hwtag=yesfoot];;name;int_name;1007; diff --git a/data/types.txt b/data/types.txt index cc5128e511..e15a00508d 100644 --- a/data/types.txt +++ b/data/types.txt @@ -1004,3 +1004,4 @@ place|city|capital|8 place|city|capital|9 place|city|capital|10 place|city|capital|11 +hwtag|yesfoot diff --git a/data/visibility.txt b/data/visibility.txt index 4afb508412..ca6a7f6f75 100644 --- a/data/visibility.txt +++ b/data/visibility.txt @@ -334,6 +334,7 @@ world 00000000000000000000 + nofoot 00000000000000000000 - oneway 00000000000000001111 - private 00000000000000000000 - + yesfoot 00000000000000000000 - {} internet_access 00000000000000000111 + wlan 00000000000000000111 - diff --git a/generator/generator_tests/osm_type_test.cpp b/generator/generator_tests/osm_type_test.cpp index 2e84e4480f..2ffee47a17 100644 --- a/generator/generator_tests/osm_type_test.cpp +++ b/generator/generator_tests/osm_type_test.cpp @@ -507,7 +507,7 @@ UNIT_TEST(OsmType_Amenity) UNIT_TEST(OsmType_Hwtag) { char const * tags[][2] = { - {"hwtag", "oneway"}, {"hwtag", "private"}, {"hwtag", "lit"}, {"hwtag", "nofoot"}, + {"hwtag", "oneway"}, {"hwtag", "private"}, {"hwtag", "lit"}, {"hwtag", "nofoot"}, {"hwtag", "yesfoot"}, }; { @@ -560,8 +560,9 @@ UNIT_TEST(OsmType_Hwtag) FeatureParams params; ftype::GetNameAndType(&e, params); - TEST_EQUAL(params.m_Types.size(), 1, (params)); + TEST_EQUAL(params.m_Types.size(), 2, (params)); TEST(params.IsTypeExist(GetType(arr[1])), ()); + TEST(params.IsTypeExist(GetType(tags[4])), ()); } } diff --git a/generator/osm2type.cpp b/generator/osm2type.cpp index fca058c90c..e9e697db54 100644 --- a/generator/osm2type.cpp +++ b/generator/osm2type.cpp @@ -292,10 +292,21 @@ namespace ftype struct Rule { char const * key; + // * - take any values + // ! - take only negative values + // ~ - take only positive values char const * value; function func; }; + static bool IsNegative(string const & value) + { + for (char const * s : { "no", "none", "false" }) + if (value == s) + return true; + return false; + } + XMLElement * m_element; public: @@ -305,14 +316,21 @@ namespace ftype void ApplyRules(initializer_list> const & rules) const { for (auto & e : m_element->childs) - { if (e.tagKey == XMLElement::ET_TAG) - { for (auto const & rule: rules) - if ((e.k == "*" || e.k == rule.key) && (e.v == "*" || e.v == rule.value)) - call(rule.func, e.k, e.v); - } - } + if (e.k == rule.key) + { + bool take = false; + if (rule.value[0] == '*') + take = true; + else if (rule.value[0] == '!') + take = IsNegative(e.v); + else if (rule.value[0] == '~') + take = !IsNegative(e.v); + + if (take || e.v == rule.value) + call(rule.func, e.k, e.v); + } } protected: @@ -362,7 +380,7 @@ namespace ftype buffer_vector m_types; public: - enum EType { ENTRANCE, HIGHWAY, ADDRESS, ONEWAY, PRIVATE, LIT, NOFOOT }; + enum EType { ENTRANCE, HIGHWAY, ADDRESS, ONEWAY, PRIVATE, LIT, NOFOOT, YESFOOT }; CachedTypes() { @@ -374,7 +392,7 @@ namespace ftype StringIL arr[] = { {"building", "address"}, {"hwtag", "oneway"}, {"hwtag", "private"}, - {"hwtag", "lit"}, {"hwtag", "nofoot"} + {"hwtag", "lit"}, {"hwtag", "nofoot"}, {"hwtag", "yesfoot"} }; for (auto const & e : arr) m_types.push_back(c.GetTypeByPath(e)); @@ -471,8 +489,13 @@ namespace ftype { "oneway", "1", [¶ms]() { params.AddType(types.Get(CachedTypes::ONEWAY)); }}, { "oneway", "-1", [¶ms]() { params.AddType(types.Get(CachedTypes::ONEWAY)); params.m_reverseGeometry = true; }}, { "access", "private", [¶ms]() { params.AddType(types.Get(CachedTypes::PRIVATE)); }}, - { "lit", "yes", [¶ms]() { params.AddType(types.Get(CachedTypes::LIT)); }}, - { "foot", "no", [¶ms]() { params.AddType(types.Get(CachedTypes::NOFOOT)); }}, + { "lit", "~", [¶ms]() { params.AddType(types.Get(CachedTypes::LIT)); }}, + + { "foot", "!", [¶ms]() { params.AddType(types.Get(CachedTypes::NOFOOT)); }}, + { "sidewalk", "!", [¶ms]() { params.AddType(types.Get(CachedTypes::NOFOOT)); }}, + + { "foot", "~", [¶ms]() { params.AddType(types.Get(CachedTypes::YESFOOT)); }}, + { "sidewalk", "~", [¶ms]() { params.AddType(types.Get(CachedTypes::YESFOOT)); }}, }); break; }