| 132 | } |
| 133 | |
| 134 | void 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 | |
| 183 | void RestrictionWriter::Finish() |
| 184 | { |