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>2012-10-20 15:45:07 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:45:57 +0300
commit9c3cc8be68cea1780b00de848f3bf7da859a2931 (patch)
tree24c1a153294e909fda4e093b269b522ca3892a20 /indexer
parent33563e317580071a2b06edd0d8cd7264bdbc824a (diff)
[generator] Avoid duplicating for "place" in closed area features that are transformed to point features.
Diffstat (limited to 'indexer')
-rw-r--r--indexer/feature_visibility.cpp44
-rw-r--r--indexer/feature_visibility.hpp35
2 files changed, 45 insertions, 34 deletions
diff --git a/indexer/feature_visibility.cpp b/indexer/feature_visibility.cpp
index a32f9b13b9..5e88bb51cc 100644
--- a/indexer/feature_visibility.cpp
+++ b/indexer/feature_visibility.cpp
@@ -404,37 +404,6 @@ pair<int, int> GetDrawableScaleRangeForRules(FeatureBase const & f, int rules)
return GetDrawableScaleRangeForRules(TypesHolder(f), rules);
}
-bool IsHighway(vector<uint32_t> const & types)
-{
- ClassifObject const * pRoot = classif().GetRoot();
-
- for (size_t i = 0; i < types.size(); ++i)
- {
- uint8_t v;
- CHECK(ftype::GetValue(types[i], 0, v), (types[i]));
- {
- if (pRoot->GetObject(v)->GetName() == "highway")
- return true;
- }
- }
-
- return false;
-}
-
-/*
-bool IsJunction(vector<uint32_t> const & types)
-{
- char const * arr[] = { "highway", "motorway_junction" };
- static const uint32_t type = classif().GetTypeByPath(vector<string>(arr, arr + 2));
-
- for (size_t i = 0; i < types.size(); ++i)
- if (types[i] == type)
- return true;
-
- return false;
-}
-*/
-
bool UsePopulationRank(uint32_t type)
{
class CheckerT
@@ -471,4 +440,17 @@ bool UsePopulationRank(uint32_t type)
return (checker.IsMyType(type));
}
+
+void TypeSetChecker::SetType(StringT * beg, StringT * end)
+{
+ m_type = classif().GetTypeByPath(vector<string>(beg, end));
+ m_level = distance(beg, end);
+}
+
+bool TypeSetChecker::IsEqual(uint32_t type) const
+{
+ ftype::TruncValue(type, m_level);
+ return (m_type == type);
+}
+
}
diff --git a/indexer/feature_visibility.hpp b/indexer/feature_visibility.hpp
index 65d28220e7..d5c1ca0586 100644
--- a/indexer/feature_visibility.hpp
+++ b/indexer/feature_visibility.hpp
@@ -57,9 +57,6 @@ namespace feature
pair<int, bool> GetDrawRule(FeatureBase const & f, int level,
vector<drule::Key> & keys, string & names);
- bool IsHighway(vector<uint32_t> const & types);
- //bool IsJunction(vector<uint32_t> const & types);
-
bool UsePopulationRank(uint32_t type);
template <class IterT>
@@ -72,4 +69,36 @@ namespace feature
}
return false;
}
+
+ /// Used to check whether user types belong to particular classificator set.
+ class TypeSetChecker
+ {
+ uint32_t m_type;
+ uint8_t m_level;
+
+ typedef char const * StringT;
+ void SetType(StringT * beg, StringT * end);
+
+ public:
+ /// Construct by classificator set name.
+ //@{
+ TypeSetChecker(StringT name) { SetType(&name, &name + 1); }
+ TypeSetChecker(StringT arr[], size_t n) { SetType(arr, arr + n); }
+ //@}
+
+ bool IsEqual(uint32_t type) const;
+ template <class IterT> bool IsEqualR(IterT beg, IterT end) const
+ {
+ while (beg != end)
+ {
+ if (IsEqual(*beg++))
+ return true;
+ }
+ return false;
+ }
+ bool IsEqualV(vector<uint32_t> const & v) const
+ {
+ return IsEqualR(v.begin(), v.end());
+ }
+ };
}