| 106 | } |
| 107 | |
| 108 | void done() |
| 109 | { |
| 110 | // Close and clear the point encoder. |
| 111 | if (m_compressor) |
| 112 | { |
| 113 | m_compressor->done(); |
| 114 | newChunk(); |
| 115 | } |
| 116 | |
| 117 | // If we didn't write any points, chunk info pos will be 0 and we need to |
| 118 | // set the chunk info pos. Could do this as an "else" case of the |
| 119 | // above, but this seems safer in case some other compressor creation logic |
| 120 | // comes about. |
| 121 | if (m_chunkInfoPos == 0) |
| 122 | { |
| 123 | m_chunkInfoPos = m_stream.tellp(); |
| 124 | m_stream.seekp(sizeof(uint64_t), std::ios::cur); |
| 125 | } |
| 126 | |
| 127 | // Save our current position. Go to the location where we need |
| 128 | // to write the chunk table offset at the beginning of the point data. |
| 129 | std::streampos chunkTablePos = m_stream.tellp(); |
| 130 | m_stream.seekp(m_chunkInfoPos); |
| 131 | OLeStream out(&m_stream); |
| 132 | out << (uint64_t)chunkTablePos; |
| 133 | |
| 134 | // Move to the start of the chunk table. |
| 135 | m_stream.seekp(chunkTablePos); |
| 136 | |
| 137 | // Write the chunk table header. |
| 138 | out << (uint32_t)0; // Version (?) |
| 139 | out << (uint32_t)m_chunkTable.size(); |
| 140 | |
| 141 | lazperf::OutFileStream stream(m_stream); |
| 142 | lazperf::compress_chunk_table(stream.cb(), m_chunkTable); |
| 143 | } |
| 144 | |
| 145 | private: |
| 146 | void resetCompressor() |