| 99 | } |
| 100 | |
| 101 | void GpsTrackRenderer::UpdatePoints(std::vector<GpsTrackPoint> const & toAdd, std::vector<uint32_t> const & toRemove) |
| 102 | { |
| 103 | bool recreateSpline = false; |
| 104 | if (!toRemove.empty()) |
| 105 | { |
| 106 | size_t const szBefore = m_points.size(); |
| 107 | base::EraseIf(m_points, [&toRemove](GpsTrackPoint const & pt) { return base::IsExist(toRemove, pt.m_id); }); |
| 108 | |
| 109 | if (szBefore > m_points.size()) // if removed any |
| 110 | { |
| 111 | recreateSpline = true; |
| 112 | m_needUpdate = true; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | if (!toAdd.empty()) |
| 117 | { |
| 118 | ASSERT(is_sorted(toAdd.begin(), toAdd.end(), GpsPointsSortPredicate), ()); |
| 119 | ASSERT(m_points.empty() || GpsPointsSortPredicate(m_points.back(), toAdd.front()), ()); |
| 120 | m_points.insert(m_points.end(), toAdd.begin(), toAdd.end()); |
| 121 | m_needUpdate = true; |
| 122 | } |
| 123 | |
| 124 | if (recreateSpline) // Recreate Spline only if Remove (Clear) was invoked. |
| 125 | { |
| 126 | m_pointsSpline = m2::Spline(m_points.size()); |
| 127 | for (auto const & p : m_points) |
| 128 | m_pointsSpline.AddPoint(p.m_point); |
| 129 | } |
| 130 | else // Simple append points otherwise. |
| 131 | { |
| 132 | for (auto const & p : toAdd) |
| 133 | m_pointsSpline.AddPoint(p.m_point); |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | size_t GpsTrackRenderer::GetAvailablePointsCount() const |
| 138 | { |
no test coverage detected