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>2013-12-03 04:02:36 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:08:11 +0300
commit325bc9181d5b8976f33e87c66feacf8c9ff2e89b (patch)
tree27ad7afdd3f0bf648055061d60eb19ca6d638220 /generator/generator_tests/classificator_tests.cpp
parent42bb40a084bcdfec00506e86e68418516c7f3cfd (diff)
[styles] Next draw order (from downmost to upmost):
- ocean - land, island - forest, grass, farm - water, lake, basin
Diffstat (limited to 'generator/generator_tests/classificator_tests.cpp')
-rw-r--r--generator/generator_tests/classificator_tests.cpp85
1 files changed, 85 insertions, 0 deletions
diff --git a/generator/generator_tests/classificator_tests.cpp b/generator/generator_tests/classificator_tests.cpp
index 878d841c5e..89c9d14f9a 100644
--- a/generator/generator_tests/classificator_tests.cpp
+++ b/generator/generator_tests/classificator_tests.cpp
@@ -121,3 +121,88 @@ UNIT_TEST(Classificator_DrawingRules)
CheckLineStyles(c, "waterway");
//CheckLineStyles(c, "railway");
}
+
+namespace
+{
+
+pair<int, int> GetMinMax(int level, vector<uint32_t> const & types)
+{
+ pair<int, int> res(numeric_limits<int>::max(), numeric_limits<int>::min());
+
+ drule::KeysT keys;
+ feature::GetDrawRule(types, level, feature::FEATURE_TYPE_AREA, keys);
+
+ for (size_t i = 0; i < keys.size(); ++i)
+ {
+ if (keys[i].m_type != drule::area)
+ continue;
+
+ if (keys[i].m_priority < res.first)
+ res.first = keys[i].m_priority;
+ if (keys[i].m_priority > res.second)
+ res.second = keys[i].m_priority;
+ }
+
+ return res;
+}
+
+}
+
+// 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)
+{
+ classificator::Load();
+ 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 };
+
+ size_t ind = 0;
+ for (size_t i = 0; i < ARRAY_SIZE(arrI); ++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)));
+ ++ind;
+ }
+ }
+
+ TEST_EQUAL(ind, ARRAY_SIZE(arrT), ());
+
+ 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> const mm = GetMinMax(level, types[i]);
+ TEST_LESS(minmax.second, mm.first, (i));
+ minmax = mm;
+ }
+ }
+}