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

Method Append

libs/map/gps_track_storage.cpp:167–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167void GpsTrackStorage::Append(vector<TItem> const & items)
168{
169 ASSERT(m_stream.is_open(), ());
170
171 if (items.empty())
172 return;
173
174 // Write position must be after last item position
175 ASSERT_EQUAL(m_stream.tellp(), static_cast<typename fstream::pos_type>(GetItemOffset(m_itemCount)), ());
176
177 vector<char> buff(min(kItemBlockSize, items.size()) * kPointSize);
178 for (size_t i = 0; i < items.size();)
179 {
180 size_t const n = min(items.size() - i, kItemBlockSize);
181
182 for (size_t j = 0; j < n; ++j)
183 Pack(&buff[0] + j * kPointSize, items[i + j]);
184
185 m_stream.write(&buff[0], n * kPointSize);
186 if (!m_stream.good())
187 MYTHROW(WriteException, ("File:", m_filePath));
188
189 i += n;
190 }
191
192 m_stream.flush();
193 if (!m_stream.good())
194 MYTHROW(WriteException, ("File:", m_filePath));
195
196 m_itemCount += items.size();
197}
198
199void GpsTrackStorage::Clear()
200{

Callers 3

UpdateStorageMethod · 0.45
AddTransitShapesFunction · 0.45
UNIT_TESTFunction · 0.45

Calls 6

ASSERTFunction · 0.85
GetItemOffsetFunction · 0.85
PackFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45
writeMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.36