| 399 | |
| 400 | |
| 401 | void CopcReader::fetchHeader() |
| 402 | { |
| 403 | // Read the LAS header, COPC info VLR header and COPC VLR |
| 404 | int size = 589; |
| 405 | std::vector<char> data = fetch(0, size); |
| 406 | |
| 407 | const char *d = data.data(); |
| 408 | m_p->header.fill(d, data.size()); |
| 409 | m_p->scaling.m_xXform = XForm(m_p->header.scale.x, m_p->header.offset.x); |
| 410 | m_p->scaling.m_yXform = XForm(m_p->header.scale.y, m_p->header.offset.y); |
| 411 | m_p->scaling.m_zXform = XForm(m_p->header.scale.z, m_p->header.offset.z); |
| 412 | |
| 413 | d += m_p->header.size(); |
| 414 | size -= m_p->header.size(); |
| 415 | |
| 416 | // Read the header - ignore the data. |
| 417 | las::Vlr vlr; |
| 418 | vlr.fillHeader(d); |
| 419 | |
| 420 | // Read VLR payload into COPC struct. |
| 421 | d += las::Vlr::HeaderSize; |
| 422 | size -= las::Vlr::HeaderSize; |
| 423 | |
| 424 | if (!Utils::iequals(vlr.userId, "copc")) |
| 425 | { |
| 426 | std::stringstream msg; |
| 427 | msg << "The first VLR in a COPC file is required to have " |
| 428 | << "user_id of 'copc' and this file has '" << vlr.userId |
| 429 | << "'"; |
| 430 | throwError(msg.str()); |
| 431 | |
| 432 | } |
| 433 | |
| 434 | if (size != 160) |
| 435 | { |
| 436 | std::stringstream msg; |
| 437 | msg << "Fetched COPC VLR size is in correct. It should " |
| 438 | << "be 160 and it is " << size; |
| 439 | throwError(msg.str()); |
| 440 | } |
| 441 | m_p->copc_info.fill(d, size); |
| 442 | |
| 443 | m_p->rootNodeExtent = BOX3D( |
| 444 | m_p->copc_info.center_x - m_p->copc_info.halfsize, |
| 445 | m_p->copc_info.center_y - m_p->copc_info.halfsize, |
| 446 | m_p->copc_info.center_z - m_p->copc_info.halfsize, |
| 447 | m_p->copc_info.center_x + m_p->copc_info.halfsize, |
| 448 | m_p->copc_info.center_y + m_p->copc_info.halfsize, |
| 449 | m_p->copc_info.center_z + m_p->copc_info.halfsize); |
| 450 | |
| 451 | validateHeader(m_p->header); |
| 452 | validateVlrInfo(vlr, m_p->copc_info); |
| 453 | } |
| 454 | |
| 455 | |
| 456 | las::VlrList CopcReader::fetchSrsVlrs(const las::VlrCatalog& catalog) |