Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2014-08-29 16:52:46 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:25:44 +0300
commit6f838013e39a8bf279371b36b7eef0389f76db4b (patch)
treefca0f8ffe0e3800fe7ceca14b1a3a5c35f9adf4e
parentbc2849d17f8c958f3e85b7af1567c615e631a030 (diff)
[generator] Process “capital = yes” only tags to get “place-city-capital” type.
-rw-r--r--generator/generator_tests/osm_type_test.cpp37
-rw-r--r--generator/osm2type.cpp21
2 files changed, 55 insertions, 3 deletions
diff --git a/generator/generator_tests/osm_type_test.cpp b/generator/generator_tests/osm_type_test.cpp
index ffb9a406fd..6e6d190726 100644
--- a/generator/generator_tests/osm_type_test.cpp
+++ b/generator/generator_tests/osm_type_test.cpp
@@ -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)), ());
+ }
+}
diff --git a/generator/osm2type.cpp b/generator/osm2type.cpp
index db2a56504e..5edaf36a1f 100644
--- a/generator/osm2type.cpp
+++ b/generator/osm2type.cpp
@@ -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;
}