| 80 | } |
| 81 | |
| 82 | void UserMarkGenerator::UpdateIndex(kml::MarkGroupId groupId) |
| 83 | { |
| 84 | for (auto & tileGroups : m_index) |
| 85 | { |
| 86 | auto itGroupIndexes = tileGroups.second->find(groupId); |
| 87 | if (itGroupIndexes != tileGroups.second->end()) |
| 88 | { |
| 89 | itGroupIndexes->second->m_markIds.clear(); |
| 90 | itGroupIndexes->second->m_lineIds.clear(); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | auto const groupIt = m_groups.find(groupId); |
| 95 | if (groupIt == m_groups.end()) |
| 96 | return; |
| 97 | |
| 98 | IDCollections & idCollection = *groupIt->second; |
| 99 | |
| 100 | for (auto const & markId : idCollection.m_markIds) |
| 101 | { |
| 102 | UserMarkRenderParams const & params = *m_marks[markId]; |
| 103 | for (int zoomLevel = params.m_minZoom; zoomLevel <= scales::GetUpperScale(); ++zoomLevel) |
| 104 | { |
| 105 | TileKey const tileKey = GetTileKeyByPoint(params.m_pivot, zoomLevel); |
| 106 | auto groupIDs = GetIdCollection(tileKey, groupId); |
| 107 | groupIDs->m_markIds.push_back(markId); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | for (auto const & lineId : idCollection.m_lineIds) |
| 112 | { |
| 113 | // Collect unique intersected tiles. |
| 114 | std::set<TileKey> tiles; |
| 115 | |
| 116 | UserLineRenderParams const & params = *m_lines[lineId]; |
| 117 | |
| 118 | int const startZoom = GetNearestLineIndexZoom(params.m_minZoom); |
| 119 | for (int zoomLevel : kLineIndexingLevels) |
| 120 | { |
| 121 | if (zoomLevel < startZoom) |
| 122 | continue; |
| 123 | |
| 124 | // Process spline by segments that are no longer than tile size. |
| 125 | double const maxLength = mercator::Bounds::kRangeX / (1 << (zoomLevel - 1)); |
| 126 | |
| 127 | for (auto const & spline : params.m_splines) |
| 128 | { |
| 129 | df::ProcessSplineSegmentRects(spline, maxLength, [&](m2::RectD const & segmentRect) |
| 130 | { |
| 131 | CalcTilesCoverage(segmentRect, zoomLevel, |
| 132 | [&](int tileX, int tileY) { tiles.emplace(tileX, tileY, zoomLevel); }); |
| 133 | return true; |
| 134 | }); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | for (auto const & tileKey : tiles) |
| 139 | { |
nothing calls this directly
no test coverage detected