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

Method CollectRelation

generator/restriction_writer.cpp:134–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134void RestrictionWriter::CollectRelation(RelationElement const & relationElement)
135{
136 std::vector<RelationElement::Member> from;
137 std::vector<RelationElement::Member> via;
138 std::vector<RelationElement::Member> to;
139
140 if (!ValidateOsmRestriction(from, via, to, relationElement))
141 return;
142
143 uint64_t const fromOsmId = from.back().first;
144 uint64_t const toOsmId = to.back().first;
145
146 // Extracting type of restriction.
147 auto const tagIt = relationElement.m_tags.find("restriction");
148 if (tagIt == relationElement.m_tags.end())
149 return;
150
151 Restriction::Type type = Restriction::Type::No;
152 if (!TagToType(tagIt->second, type))
153 return;
154
155 auto const viaType =
156 GetType(relationElement, via.back().first) == OsmElement::EntityType::Node ? ViaType::Node : ViaType::Way;
157
158 auto const printHeader = [&]() { m_stream << DebugPrint(type) << "," << DebugPrint(viaType) << ","; };
159
160 if (viaType == ViaType::Way)
161 {
162 printHeader();
163 m_stream << fromOsmId << ",";
164 for (auto const & viaMember : via)
165 m_stream << viaMember.first << ",";
166 }
167 else
168 {
169 double y = 0.0;
170 double x = 0.0;
171 uint64_t const viaNodeOsmId = via.back().first;
172 if (!m_cache->GetNode(viaNodeOsmId, y, x))
173 return;
174
175 printHeader();
176 m_stream << x << "," << y << ",";
177 m_stream << fromOsmId << ",";
178 }
179
180 m_stream << toOsmId << '\n';
181}
182
183void RestrictionWriter::Finish()
184{

Callers 2

operator()Method · 0.45
UNIT_TESTFunction · 0.45

Calls 8

ValidateOsmRestrictionFunction · 0.85
TagToTypeFunction · 0.85
backMethod · 0.80
GetTypeFunction · 0.70
DebugPrintFunction · 0.70
findMethod · 0.45
endMethod · 0.45
GetNodeMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.36