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>2016-04-14 18:04:08 +0300
committervng <viktor.govako@gmail.com>2016-04-21 13:54:18 +0300
commit0c329c16728fc9c149761c381b567870e76e0073 (patch)
tree054f6704a8f2b46abb185226de7fe3cd201bed43 /map/style_tests
parentb786254cafb7561689e80e7f701ac271bf3c3cf8 (diff)
[tests] Added POI priority tests.
Diffstat (limited to 'map/style_tests')
-rw-r--r--map/style_tests/classificator_tests.cpp113
1 files changed, 73 insertions, 40 deletions
diff --git a/map/style_tests/classificator_tests.cpp b/map/style_tests/classificator_tests.cpp
index d9d06c4d18..9f88f38897 100644
--- a/map/style_tests/classificator_tests.cpp
+++ b/map/style_tests/classificator_tests.cpp
@@ -130,7 +130,7 @@ UNIT_TEST(Classificator_DrawingRules)
namespace
{
-pair<int, int> GetMinMax(int level, vector<uint32_t> const & types)
+pair<int, int> GetMinMax(int level, vector<uint32_t> const & types, drule::rule_type_t ruleType)
{
pair<int, int> res(numeric_limits<int>::max(), numeric_limits<int>::min());
@@ -139,7 +139,7 @@ pair<int, int> GetMinMax(int level, vector<uint32_t> const & types)
for (size_t i = 0; i < keys.size(); ++i)
{
- if (keys[i].m_type != drule::area)
+ if (keys[i].m_type != ruleType)
continue;
if (keys[i].m_priority < res.first)
@@ -151,62 +151,36 @@ pair<int, int> GetMinMax(int level, vector<uint32_t> const & types)
return res;
}
-} // namespace
-
-// Check area drawing priority according to the types order below (from downmost to upmost).
-// If someone is desagree with this order, please, refer to VNG :)
-// natural-coastline
-// place-island = natural-land
-// natural-wood,scrub,heath,grassland = landuse-grass,farm,farmland,forest
-// natural-water,lake = landuse-basin
-
-UNIT_TEST(Classificator_AreaPriority)
+void CheckPriority(vector<StringIL> const & arrT, vector<size_t> const & arrI, drule::rule_type_t ruleType)
{
- styles::RunForEveryMapStyle([](MapStyle)
- {
- Classificator const & c = classif();
-
- vector<vector<uint32_t> > types;
+ Classificator const & c = classif();
+ vector<vector<uint32_t> > types;
- char const * arrT[][2] =
- {
- // 0
- {"natural", "coastline"},
- // 1
- //{"waterway", "riverbank"}, - it's not a good idea to place it here
- // 2
- {"place", "island"}, {"natural", "land"},
- // 3
- {"natural", "wood"}, {"natural", "scrub"}, {"natural", "heath"}, {"natural", "grassland"},
- {"landuse", "grass"}, {"landuse", "farm"}, {"landuse", "farmland"}, {"landuse", "forest"},
- // 4
- //{"leisure", "park"}, {"leisure", "garden"}, - maybe next time (too tricky to do it now)
- // 5
- {"natural", "water"}, {"natural", "lake"}, {"landuse", "basin"}
- };
- size_t arrI[] = { 1, 2, 8, 3 };
+ styles::RunForEveryMapStyle([&](MapStyle)
+ {
+ types.clear();
size_t ind = 0;
- for (size_t i = 0; i < ARRAY_SIZE(arrI); ++i)
+ for (size_t i = 0; i < arrI.size(); ++i)
{
types.push_back(vector<uint32_t>());
types.back().reserve(arrI[i]);
for (size_t j = 0; j < arrI[i]; ++j)
{
- types.back().push_back(c.GetTypeByPath(vector<string>(arrT[ind], arrT[ind] + 2)));
+ types.back().push_back(c.GetTypeByPath(arrT[ind]));
++ind;
}
}
- TEST_EQUAL(ind, ARRAY_SIZE(arrT), ());
+ TEST_EQUAL(ind, arrT.size(), ());
for (int level = scales::GetUpperWorldScale() + 1; level <= scales::GetUpperStyleScale(); ++level)
{
- pair<int, int> minmax = GetMinMax(level, types[0]);
- for (size_t i = 1; i < types.size(); ++i)
+ pair<int, int> minmax(numeric_limits<int>::max(), numeric_limits<int>::min());
+ for (size_t i = 0; i < types.size(); ++i)
{
- pair<int, int> const mm = GetMinMax(level, types[i]);
+ pair<int, int> const mm = GetMinMax(level, types[i], ruleType);
TEST_LESS(minmax.second, mm.first, (i));
minmax = mm;
}
@@ -214,6 +188,65 @@ UNIT_TEST(Classificator_AreaPriority)
});
}
+} // namespace
+
+// Check area drawing priority according to the types order below (from downmost to upmost).
+// If someone is desagree with this order, please, refer to VNG :)
+// natural-coastline
+// place-island = natural-land
+// natural-wood,scrub,heath,grassland = landuse-grass,farm,farmland,forest
+// natural-water,lake = landuse-basin
+
+UNIT_TEST(Classificator_AreaPriority)
+{
+ vector<StringIL> types =
+ {
+ // 0
+ {"natural", "coastline"},
+ // 1
+ //{"waterway", "riverbank"}, - it's not a good idea to place it here
+ // 2
+ {"place", "island"}, {"natural", "land"},
+ // 3
+ {"natural", "wood"}, {"natural", "scrub"}, {"natural", "heath"}, {"natural", "grassland"},
+ {"landuse", "grass"}, {"landuse", "farm"}, {"landuse", "farmland"}, {"landuse", "forest"},
+ // 4
+ //{"leisure", "park"}, {"leisure", "garden"}, - maybe next time (too tricky to do it now)
+ // 5
+ {"natural", "water"}, {"natural", "lake"}, {"landuse", "basin"}
+ };
+
+ CheckPriority(types, {1, 2, 8, 3}, drule::area);
+}
+
+UNIT_TEST(Classificator_PoiPriority)
+{
+ {
+ vector<StringIL> types =
+ {
+ // 1
+ {"amenity", "atm"},
+ // 2
+ {"amenity", "bank"}
+ };
+
+ CheckPriority(types, {1, 1}, drule::symbol);
+ }
+
+ {
+ vector<StringIL> types =
+ {
+ // 1
+ {"amenity", "bench"}, {"amenity", "shelter"},
+ // 2
+ {"highway", "bus_stop"}, {"amenity", "bus_station"},
+ {"railway", "station"}, {"railway", "halt"}, {"railway", "tram_stop"},
+ };
+
+ CheckPriority(types, {2, 5}, drule::symbol);
+ }
+}
+
UNIT_TEST(Classificator_GetType)
{
classificator::Load();