| 168 | } |
| 169 | |
| 170 | void GpsTrack::InitCollection() |
| 171 | { |
| 172 | ASSERT(m_collection == nullptr, ()); |
| 173 | |
| 174 | m_collection = make_unique<GpsTrackCollection>(); |
| 175 | |
| 176 | InitStorageIfNeed(); |
| 177 | if (!m_storage) |
| 178 | return; |
| 179 | |
| 180 | try |
| 181 | { |
| 182 | // All origin points have been written in the storage, |
| 183 | // and filtered points are inserted in the runtime collection. |
| 184 | |
| 185 | vector<location::GpsInfo> originPoints; |
| 186 | originPoints.reserve(gps_track::kItemBlockSize); |
| 187 | |
| 188 | m_storage->ForEach([this, &originPoints](location::GpsInfo const & originPoint) -> bool |
| 189 | { |
| 190 | originPoints.emplace_back(originPoint); |
| 191 | if (originPoints.size() == originPoints.capacity()) |
| 192 | { |
| 193 | vector<location::GpsInfo> points; |
| 194 | m_filter->Process(originPoints, points); |
| 195 | |
| 196 | m_collection->Add(points); |
| 197 | |
| 198 | originPoints.clear(); |
| 199 | } |
| 200 | return true; |
| 201 | }); |
| 202 | |
| 203 | if (!originPoints.empty()) |
| 204 | { |
| 205 | vector<location::GpsInfo> points; |
| 206 | m_filter->Process(originPoints, points); |
| 207 | |
| 208 | m_collection->Add(points); |
| 209 | } |
| 210 | } |
| 211 | catch (RootException const & e) |
| 212 | { |
| 213 | LOG(LWARNING, ("Track storage exception:", e.Msg())); |
| 214 | m_collection->Clear(); |
| 215 | m_storage.reset(); |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | void GpsTrack::ProcessPoints() |
| 220 | { |
nothing calls this directly
no test coverage detected