[generator] Process “capital = yes” only tags to get “place-city-capital” type.

This commit is contained in:
vng 2014-08-29 15:52:46 +03:00 committed by Alex Zolotarev
parent bc2849d17f
commit 6f838013e3
2 changed files with 55 additions and 3 deletions

View file

@ -299,3 +299,40 @@ UNIT_TEST(OsmType_Synonyms)
TEST(params.IsTypeExist(GetType(arrT)), ());
}
}
UNIT_TEST(OsmType_Capital)
{
{
char const * arr[][2] = {
{ "place", "city" },
{ "capital", "yes" }
};
XMLElement e;
FillXmlElement(arr, ARRAY_SIZE(arr), &e);
FeatureParams params;
ftype::GetNameAndType(&e, params);
TEST_EQUAL(params.m_Types.size(), 1, ());
char const * type[] = { "place", "city", "capital" };
TEST(params.IsTypeExist(GetType(type)), ());
}
{
char const * arr[][2] = {
{ "place", "city" },
{ "capital", "6" }
};
XMLElement e;
FillXmlElement(arr, ARRAY_SIZE(arr), &e);
FeatureParams params;
ftype::GetNameAndType(&e, params);
TEST_EQUAL(params.m_Types.size(), 1, ());
char const * type[] = { "place", "city" };
TEST(params.IsTypeExist(GetType(type)), ());
}
}

View file

@ -208,9 +208,24 @@ namespace ftype
if (is_name_tag(k))
return false;
uint64_t dummy;
if (!m_isKey && strings::to_uint64(v, dummy))
return (k == "admin_level");
// Filter 3rd component of type here.
if (m_isKey)
{
/// @todo Probably, we need to filter most keys like == "yes" here,
/// but need to carefully investigate the classificator.
// Grab only "capital == yes" and skip all other capitals.
if (k == "capital")
return (get_mark_value(k, v) == 1);
}
else
{
// Numbers are used in boundary-administrative-X types.
// Take only "admin_level" tags to avoid grabbing any other trash numbers.
uint64_t dummy;
if (strings::to_uint64(v, dummy))
return (k == "admin_level");
}
return true;
}