MCPcopy Create free account
hub / github.com/PDAL/PDAL / writeCompressed

Method writeCompressed

io/private/copcwriter/Processor.cpp:167–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165
166
167void Processor::writeCompressed(VoxelKey k, PointViewPtr v)
168{
169 if (v->size() == 0)
170 {
171 m_manager.newChunk(k, 0, 0);
172 return;
173 }
174
175 PointLayoutPtr layout = v->layout();
176
177 std::vector<char> buf(lazperf::baseCount(b.pointFormatId) + b.numExtraBytes);
178 lazperf::writer::chunk_compressor compressor(b.pointFormatId, b.numExtraBytes);
179
180 // Sort by GPS time - no-op if there's no GPS time.
181 v->sort(Dimension::Id::GpsTime);
182
183 for (PointId idx = 0; idx < v->size(); ++idx)
184 {
185 PointRef point(*v, idx);
186 m_loader.pack(point, buf.data(), buf.size());
187 compressor.compress(buf.data());
188 }
189 std::vector<unsigned char> chunk = compressor.done();
190 uint64_t location = m_manager.newChunk(k, (uint32_t)chunk.size(), (uint32_t)v->size());
191
192 std::ofstream out(b.filename, std::ios::out | std::ios::in | std::ios::binary);
193 out.seekp(std::ofstream::pos_type(location));
194 out.write(reinterpret_cast<const char *>(chunk.data()), chunk.size());
195 out.close();
196 if (!out)
197 throw pdal_error("Failure writing to '" + b.filename + "'.");
198}
199
200} // namespace copcwriter
201} // namespace pdal

Callers

nothing calls this directly

Calls 10

baseCountFunction · 0.85
sortMethod · 0.80
packMethod · 0.80
sizeMethod · 0.45
newChunkMethod · 0.45
dataMethod · 0.45
compressMethod · 0.45
doneMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected