[classificator][generator] Added “hwtag-yesfoot” and it’s processing routine.

This commit is contained in:
vng 2015-07-07 15:29:01 +03:00 committed by Alex Zolotarev
parent f640dd75a4
commit 9e4c2dfe41
6 changed files with 40 additions and 12 deletions

View file

@ -334,6 +334,7 @@ world +
nofoot -
oneway -
private -
yesfoot -
{}
internet_access +
wlan -

View file

@ -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;

Can't render this file because it has a wrong number of fields in line 371.

View file

@ -1004,3 +1004,4 @@ place|city|capital|8
place|city|capital|9
place|city|capital|10
place|city|capital|11
hwtag|yesfoot

View file

@ -334,6 +334,7 @@ world 00000000000000000000 +
nofoot 00000000000000000000 -
oneway 00000000000000001111 -
private 00000000000000000000 -
yesfoot 00000000000000000000 -
{}
internet_access 00000000000000000111 +
wlan 00000000000000000111 -

View file

@ -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])), ());
}
}

View file

@ -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<FuncT> 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<Rule<FuncT>> 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<uint32_t, 16> 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", [&params]() { params.AddType(types.Get(CachedTypes::ONEWAY)); }},
{ "oneway", "-1", [&params]() { params.AddType(types.Get(CachedTypes::ONEWAY)); params.m_reverseGeometry = true; }},
{ "access", "private", [&params]() { params.AddType(types.Get(CachedTypes::PRIVATE)); }},
{ "lit", "yes", [&params]() { params.AddType(types.Get(CachedTypes::LIT)); }},
{ "foot", "no", [&params]() { params.AddType(types.Get(CachedTypes::NOFOOT)); }},
{ "lit", "~", [&params]() { params.AddType(types.Get(CachedTypes::LIT)); }},
{ "foot", "!", [&params]() { params.AddType(types.Get(CachedTypes::NOFOOT)); }},
{ "sidewalk", "!", [&params]() { params.AddType(types.Get(CachedTypes::NOFOOT)); }},
{ "foot", "~", [&params]() { params.AddType(types.Get(CachedTypes::YESFOOT)); }},
{ "sidewalk", "~", [&params]() { params.AddType(types.Get(CachedTypes::YESFOOT)); }},
});
break;
}