| 97 | |
| 98 | |
| 99 | void BpfWriter::initialize() |
| 100 | { |
| 101 | // Deal with remote files |
| 102 | if (Utils::isRemote(filename())) |
| 103 | { |
| 104 | // swap our filename for a tmp file |
| 105 | std::string tmpname = Utils::tempFilename(filename()); |
| 106 | m_remoteFilename = filename(); |
| 107 | setFilename(tmpname); |
| 108 | } |
| 109 | |
| 110 | m_header.m_coordId = m_coordId.m_val; |
| 111 | m_header.m_coordType = Utils::toNative(m_header.m_coordId ? |
| 112 | BpfCoordType::UTM : BpfCoordType::Cartesian); |
| 113 | #ifndef PDAL_HAVE_ZLIB |
| 114 | if (m_compression) |
| 115 | throwError("Can't write compressed BPF. PDAL wasn't built with " |
| 116 | "Zlib support."); |
| 117 | #endif |
| 118 | m_header.m_compression = Utils::toNative( |
| 119 | m_compression ? BpfCompression::Zlib : BpfCompression::None); |
| 120 | m_extraData = Utils::base64_decode(m_extraDataSpec); |
| 121 | |
| 122 | for (auto file : m_bundledFilesSpec) |
| 123 | { |
| 124 | if (!FileUtils::fileExists(file)) |
| 125 | throwError("Bundledfile '" + file + "' doesn't exist."); |
| 126 | |
| 127 | size_t size = FileUtils::fileSize(file); |
| 128 | if (size > (std::numeric_limits<uint32_t>::max)()) |
| 129 | throwError("Bundled file '" + file + "' too large."); |
| 130 | if (size == 0) |
| 131 | throwError("Bundled file '" + file + "' empty or otherwise invalid."); |
| 132 | |
| 133 | BpfUlemFile ulemFile(size, FileUtils::getFilename(file), file); |
| 134 | if (ulemFile.m_filename.length() > 32) |
| 135 | throwError("Bundled file '" + file + "' name exceeds " |
| 136 | "maximum length of 32."); |
| 137 | m_bundledFiles.push_back(ulemFile); |
| 138 | } |
| 139 | |
| 140 | // BPF coordinates are always in UTM meters, which can be quite large. |
| 141 | // Allowing the writer to proceed with the default offset of 0 can lead to |
| 142 | // unexpected quantization of the coordinates. Instead, we force use of |
| 143 | // auto offset to subtract the minimum value in XYZ, unless of course, the |
| 144 | // user chooses to override with their own offset. |
| 145 | if (!m_scaling.m_xOffArg->set()) |
| 146 | m_scaling.m_xXform.m_offset.m_auto = true; |
| 147 | if (!m_scaling.m_yOffArg->set()) |
| 148 | m_scaling.m_yXform.m_offset.m_auto = true; |
| 149 | if (!m_scaling.m_zOffArg->set()) |
| 150 | m_scaling.m_zXform.m_offset.m_auto = true; |
| 151 | } |
| 152 | |
| 153 | |
| 154 | void BpfWriter::prepared(PointTableRef table) |
nothing calls this directly
no test coverage detected