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

Method GetRoadShields

libs/indexer/road_shields_parser.cpp:136–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134 }
135
136 RoadShieldsSetT GetRoadShields() const
137 {
138 RoadShieldsSetT result, defaultShields;
139
140 uint8_t index = 0;
141 strings::Tokenize(m_baseRoadNumber, ";", [&](std::string_view rawText)
142 {
143 ++index;
144 RoadShield shield;
145 auto slashPos = rawText.find('/');
146 if (slashPos == std::string::npos)
147 {
148 shield = ParseRoadShield(rawText, index);
149 }
150 else
151 {
152 shield = ParseRoadShield(rawText.substr(slashPos + 1), index);
153 // TODO: use a network-based shield type override only if a parser couldn't make it
154 // more specific than country's default shield type.
155 // E.g. "94" is set to Generic_Orange by Estonia parser, but then
156 // is overriden by "ee:national" => Generic_Red.
157 // (can't override just RoadShieldType::Default, as e.g. Russia parser uses Generic_Blue as country default).
158 if (shield.m_type != RoadShieldType::Hidden)
159 {
160 RoadShieldType const networkType = FindNetworkShield(std::string(rawText.substr(0, slashPos)));
161 if (networkType != RoadShieldType::Default)
162 shield.m_type = networkType;
163 }
164 }
165 if (!shield.m_name.empty() && shield.m_type != RoadShieldType::Hidden)
166 {
167 if (shield.m_type != RoadShieldType::Default)
168 {
169 // Schedule deletion of a shield with the same text and default style, if present.
170 defaultShields.emplace_back(RoadShieldType::Default, shield.m_name, shield.m_additionalText);
171 }
172 result.push_back(std::move(shield));
173 }
174 });
175
176 result.erase_if([&defaultShields](RoadShield const & shield)
177 { return std::find(defaultShields.begin(), defaultShields.end(), shield) != defaultShields.end(); });
178
179 return result;
180 }
181
182protected:
183 std::string const m_baseRoadNumber;

Callers 1

GetRoadShieldsFunction · 0.80

Calls 9

findFunction · 0.85
erase_ifMethod · 0.80
TokenizeFunction · 0.50
findMethod · 0.45
emptyMethod · 0.45
emplace_backMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected