MCPcopy Create free account
hub / github.com/comaps/comaps / AddRule

Method AddRule

libs/indexer/drawing_rules.cpp:87–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87Key RulesHolder::AddRule(int scale, TypeT type, BaseRule * p)
88{
89 ASSERT(0 <= scale && scale <= scales::GetUpperStyleScale(), (scale));
90 ASSERT(0 <= type && type < count_of_rules, ());
91
92 m_dRules.push_back(p);
93 auto const index = m_dRules.size() - 1;
94 Key const k(scale, type, index);
95
96 ASSERT(Find(k) == p, (index));
97 return k;
98}
99
100BaseRule const * RulesHolder::Find(Key const & k) const
101{
102 ASSERT_LESS(k.m_index, m_dRules.size(), ());
103 return m_dRules[k.m_index];
104}
105
106uint32_t RulesHolder::GetBgColor(int scale) const
107{
108 ASSERT_LESS(scale, static_cast<int>(m_bgColors.size()), ());
109 ASSERT_GREATER_OR_EQUAL(scale, 0, ());
110 return m_bgColors[scale];
111}
112
113uint32_t RulesHolder::GetColor(std::string const & name) const
114{
115 auto const it = m_colors.find(name);
116 if (it == m_colors.end())
117 {
118 LOG(LWARNING, ("Requested color '" + name + "' is not found"));
119 return 0;
120 }
121 return it->second;
122}
123
124namespace
125{
126RulesHolder & rules(MapStyle mapStyle)
127{
128 static RulesHolder h[MapStyleCount];
129 return h[mapStyle];
130}
131} // namespace
132
133RulesHolder & rules()
134{
135 return rules(GetStyleReader().GetCurrentStyle());
136}
137
138namespace
139{
140namespace proto_rules
141{
142class Line : public BaseRule
143{
144 LineRuleProto m_line;

Callers 1

AddRuleMethod · 0.45

Calls 14

ASSERTFunction · 0.85
GetUpperStyleScaleFunction · 0.85
GetCurrentStyleMethod · 0.80
cont_sizeMethod · 0.60
element_sizeMethod · 0.60
has_areaMethod · 0.60
sizeMethod · 0.45
push_backMethod · 0.45
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
colorMethod · 0.45

Tested by

no test coverage detected