diff --git a/generator/classif_routine.cpp b/generator/classif_routine.cpp index 855a19f7f7..15febb056a 100644 --- a/generator/classif_routine.cpp +++ b/generator/classif_routine.cpp @@ -27,27 +27,58 @@ namespace classificator } } + /* + class DoFindSymbol + { + string m_name; + public: + DoFindSymbol(string const & name) : m_name(name) {} + + void operator() (int s, int t, int i, drule::BaseRule const * p) + { + if (s == 17 && t == drule::symbol) + { + string name; + p->GetSymbol(name); + if (name == m_name) + { + LOG(LINFO, ("Found rule with index = ", i)); + } + } + } + }; + */ + void GenerateAndWrite(string const & path) { + using namespace drule; + // Experimental - add drawing rules in program. // // 1. Read rules. // string const name = "drawing_rules.bin"; // ReaderPtrStream rulesS(GetPlatform().GetReader(name)); -// drule::ReadRules(rulesS); +// ReadRules(rulesS); -// // 2. Append rules. +// // 2. Find spesial rule. +// //rules().ForEachRule(DoFindSymbol("supermarket")); + +// // 3. Append rules. // //int const color = 0; // int const color = 0xB5D6F1; // //double const pixWidth = 1.5; // for (int i = 0; i <= scales::GetUpperScale(); ++i) // { -// //size_t const ind = drule::rules().AddLineRule(i, color, pixWidth); -// size_t const ind = drule::rules().AddAreaRule(i, color); +// //size_t const ind = rules().AddLineRule(i, color, pixWidth); +// size_t const ind = rules().AddAreaRule(i, color); // LOG_SHORT(LINFO, ("Scale = ", i, "; Index = ", ind)); // } +// //size_t const ind = rules().AddSymbolRule(17, "supermarket"); +// //LOG_SHORT(LINFO, ("Index = ", ind)); -// drule::WriteRules((path + name).c_str()); +// // 4. Write rules. +// WriteRules((path + name).c_str()); +// // 5. Exit. // return; // 1. generic types diff --git a/indexer/drawing_rules.cpp b/indexer/drawing_rules.cpp index 05f028e196..895c9d67e5 100644 --- a/indexer/drawing_rules.cpp +++ b/indexer/drawing_rules.cpp @@ -971,7 +971,7 @@ Key RulesHolder::CreateRuleImpl2(string const & name, } } -size_t RulesHolder::AddRule(int32_t scale, rule_type_t type, BaseRule * p) +size_t RulesHolder::AddRule(int scale, rule_type_t type, BaseRule * p) { ASSERT ( 0 <= scale && scale <= scales::GetUpperScale(), (scale) ); ASSERT ( 0 <= type && type < count_of_rules, () ); @@ -986,7 +986,7 @@ size_t RulesHolder::AddRule(int32_t scale, rule_type_t type, BaseRule * p) return ret; } -size_t RulesHolder::AddLineRule(int32_t scale, int color, double pixWidth) +size_t RulesHolder::AddLineRule(int scale, int color, double pixWidth) { LineRule * p = new LineRule(); p->m_params.get<4>() = color_t(color); @@ -994,13 +994,20 @@ size_t RulesHolder::AddLineRule(int32_t scale, int color, double pixWidth) return AddRule(scale, line, p); } -size_t RulesHolder::AddAreaRule(int32_t scale, int color) +size_t RulesHolder::AddAreaRule(int scale, int color) { AreaRule * p = new AreaRule(); p->m_params.get<0>() = color_t(color); return AddRule(scale, area, p); } +size_t RulesHolder::AddSymbolRule(int scale, string const & sym) +{ + SymbolRule * p = new SymbolRule(); + p->m_params.get<0>() = sym; + return AddRule(scale, symbol, p); +} + BaseRule const * RulesHolder::Find(Key const & k) const { rules_map_t::const_iterator i = m_rules.find(k.m_scale); diff --git a/indexer/drawing_rules.hpp b/indexer/drawing_rules.hpp index 664d609519..8ebc6a821c 100644 --- a/indexer/drawing_rules.hpp +++ b/indexer/drawing_rules.hpp @@ -128,9 +128,10 @@ namespace drule public: ~RulesHolder(); - size_t AddRule(int32_t scale, rule_type_t type, BaseRule * p); - size_t AddLineRule(int32_t scale, int color, double pixWidth); - size_t AddAreaRule(int32_t scale, int color); + size_t AddRule(int scale, rule_type_t type, BaseRule * p); + size_t AddLineRule(int scale, int color, double pixWidth); + size_t AddAreaRule(int scale, int color); + size_t AddSymbolRule(int scale, string const & sym); void Clean(); @@ -155,7 +156,7 @@ namespace drule for (size_t k = 0; k < v.size(); ++k) { // scale, type, rule - toDo(i->first, j, m_container[j][v[k]]); + toDo(i->first, j, v[k], m_container[j][v[k]]); } } } diff --git a/indexer/types_mapping.cpp b/indexer/types_mapping.cpp index d8f04c8c97..e25029d3a0 100644 --- a/indexer/types_mapping.cpp +++ b/indexer/types_mapping.cpp @@ -8,7 +8,7 @@ void BaseTypeMapper::Load(string const & buffer) { istringstream ss(buffer); - Classificator & c = classif(); + Classificator const & c = classif(); string v; vector path; diff --git a/map/drawer_yg.cpp b/map/drawer_yg.cpp index 94d172cb78..4b99ec0102 100644 --- a/map/drawer_yg.cpp +++ b/map/drawer_yg.cpp @@ -51,16 +51,16 @@ DrawerYG::DrawerYG(params_t const & params) namespace { - struct make_invalid + struct DoMakeInvalidRule { size_t m_threadID; uint32_t m_pipelineIDMask; - make_invalid(size_t threadID, uint8_t pipelineID) + DoMakeInvalidRule(size_t threadID, uint8_t pipelineID) : m_threadID(threadID), m_pipelineIDMask(pipelineID << 24) {} - void operator() (int, int, drule::BaseRule * p) + void operator() (int, int, int, drule::BaseRule * p) { if ((p->GetID(m_threadID) & 0xFF000000) == m_pipelineIDMask) p->MakeEmptyID(m_threadID); @@ -72,7 +72,7 @@ namespace void DrawerYG::ClearSkinPage(size_t threadID, uint8_t pipelineID) { - drule::rules().ForEachRule(make_invalid(threadID, pipelineID)); + drule::rules().ForEachRule(DoMakeInvalidRule(threadID, pipelineID)); } void DrawerYG::beginFrame()