| 240 | } |
| 241 | |
| 242 | void CopcWriter::prepared(PointTableRef table) |
| 243 | { |
| 244 | // Set the pointFormatId based on whether or not colors exist in the output. |
| 245 | PointLayoutPtr layout = table.layout(); |
| 246 | if (layout->hasDim(Dimension::Id::Infrared)) |
| 247 | b->pointFormatId = 8; |
| 248 | else if (layout->hasDim(Dimension::Id::Red) || |
| 249 | layout->hasDim(Dimension::Id::Green) || |
| 250 | layout->hasDim(Dimension::Id::Blue)) |
| 251 | b->pointFormatId = 7; |
| 252 | else |
| 253 | b->pointFormatId = 6; |
| 254 | |
| 255 | Dimension::IdList allDims = layout->dims(); |
| 256 | Dimension::IdList stdDims = las::pdrfDims(b->pointFormatId); |
| 257 | std::sort(allDims.begin(), allDims.end()); |
| 258 | std::sort(stdDims.begin(), stdDims.end()); |
| 259 | // Fill in the extraDim lists with the difference between the total list and the |
| 260 | // standard list. |
| 261 | Dimension::IdList edIds; |
| 262 | std::set_difference(allDims.begin(), allDims.end(), stdDims.begin(), stdDims.end(), |
| 263 | std::inserter(edIds, edIds.end())); |
| 264 | |
| 265 | // If 'all' was specified, add all extra dimensions to the list. |
| 266 | if (b->extraDims.size() == 1 && b->extraDims[0].m_name == "all") |
| 267 | { |
| 268 | b->extraDims.clear(); |
| 269 | int byteOffset = 0; |
| 270 | for (Dimension::Id id : edIds) |
| 271 | { |
| 272 | Dimension::Type type = layout->dimType(id); |
| 273 | const std::string& name = layout->dimName(id); |
| 274 | |
| 275 | b->extraDims.push_back(las::ExtraDim(name, type, byteOffset)); |
| 276 | byteOffset += Dimension::size(type); |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | b->numExtraBytes = 0; |
| 281 | for (las::ExtraDim& dim : b->extraDims) |
| 282 | { |
| 283 | dim.m_dimType.m_id = layout->findDim(dim.m_name); |
| 284 | if (dim.m_dimType.m_id == Dimension::Id::Unknown) |
| 285 | throwError("Dimension '" + dim.m_name + "' specified in " |
| 286 | "'extra_dim' option not found."); |
| 287 | if (Utils::contains(stdDims, dim.m_dimType.m_id)) |
| 288 | throwError("Dimension '" + dim.m_name + "' specified in " |
| 289 | "'extra_dim' option is a standard dimension."); |
| 290 | |
| 291 | // Point loader works on offsets from the start of the buffer. EB arg parsing |
| 292 | // works from zero. |
| 293 | dim.m_byteOffset += las::baseCount(b->pointFormatId); |
| 294 | b->numExtraBytes += Dimension::size(dim.m_dimType.m_type); |
| 295 | log()->get(LogLevel::Info) << getName() << ": Writing dimension " << |
| 296 | dim.m_name << |
| 297 | "(" << Dimension::interpretationName(dim.m_dimType.m_type) << |
| 298 | ") " << " to COPC extra bytes." << std::endl; |
| 299 | } |
nothing calls this directly
no test coverage detected