diff options
author | vng <viktor.govako@gmail.com> | 2012-10-09 15:04:40 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:45:02 +0300 |
commit | ebf3bccf1765fb4700c4cdd868ce372408016c08 (patch) | |
tree | 19732123a2ea401d8aaf210809e4be8853b06fa3 /indexer | |
parent | 546372dd085c2e16834e3630d682b554403f8ca6 (diff) |
[generator] Add test for checking consistency of types.txt and classificator.txt
Diffstat (limited to 'indexer')
-rw-r--r-- | indexer/classificator.hpp | 43 | ||||
-rw-r--r-- | indexer/types_mapping.hpp | 3 |
2 files changed, 21 insertions, 25 deletions
diff --git a/indexer/classificator.hpp b/indexer/classificator.hpp index d77e256614..117aa9f37b 100644 --- a/indexer/classificator.hpp +++ b/indexer/classificator.hpp @@ -98,33 +98,24 @@ public: } template <class ToDo> - void ForEachObjectConst(ToDo & toDo) const + void ForEachObjectInTree(ToDo & toDo, uint32_t const start) const { for (size_t i = 0; i < m_objs.size(); ++i) - toDo(m_objs[i]); + { + uint32_t type = start; + + ftype::PushValue(type, static_cast<uint8_t>(i)); + + toDo(&m_objs[i], type); + + m_objs[i].ForEachObjectInTree(toDo, type); + } } typedef bitset<18> visible_mask_t; visible_mask_t GetVisibilityMask() const { return m_visibility; } void SetVisibilityMask(visible_mask_t mask) { m_visibility = mask; } - //template <class ToDo> void ForEachType(int level, uint32_t type, ToDo & toDo) - //{ - // if (IsCriterion()) return; - - // if ((level > 1) || (level == 1 && m_objs.empty())) // root and first level is skipped - // { - // toDo(type); - // } - - // for (size_t i = 0; i < m_objs.size(); ++i) - // { - // uint32_t t = type; - // ftype::PushValue(t, i); - // m_objs[i].ForEachType(level + 1, t, toDo); - // } - //} - /// @name Policies for classificator tree serialization. //@{ class BasePolicy @@ -238,21 +229,23 @@ public: uint32_t GetIndexForType(uint32_t t) const { return m_mapping.GetIndex(t); } uint32_t GetTypeForIndex(uint32_t i) const { return m_mapping.GetType(i); } + bool IsTypeValid(uint32_t t) const { return m_mapping.HasIndex(t); } inline uint32_t GetCoastType() const { return m_coastType; } - // Iterate for possible objects types - //template <class ToDo> void ForEachType(ToDo toDo) - //{ - // m_root.ForEachType(0, ftype::GetEmptyValue(), toDo); - //} - /// @name used in osm2type.cpp, not for public use. //@{ ClassifObject const * GetRoot() const { return &m_root; } ClassifObject * GetMutableRoot() { return &m_root; } //@} + /// Iterate through all classificator tree. + /// Functor receives pointer to object and uint32 type. + template <class ToDo> void ForEachTree(ToDo & toDo) const + { + GetRoot()->ForEachObjectInTree(toDo, ftype::GetEmptyValue()); + } + /// @name Used only in feature_visibility.cpp, not for public use. //@{ template <class ToDo> typename ToDo::ResultType diff --git a/indexer/types_mapping.hpp b/indexer/types_mapping.hpp index 6a1f9bd496..72dcc1be62 100644 --- a/indexer/types_mapping.hpp +++ b/indexer/types_mapping.hpp @@ -25,4 +25,7 @@ public: } uint32_t GetIndex(uint32_t t) const; + + /// For Debug purposes only. + bool HasIndex(uint32_t t) const { return (m_map.find(t) != m_map.end()); } }; |