diff --git a/cpp/src/io/copc_reader.cpp b/cpp/src/io/copc_reader.cpp index f6d32142..ecb2b992 100644 --- a/cpp/src/io/copc_reader.cpp +++ b/cpp/src/io/copc_reader.cpp @@ -94,22 +94,26 @@ CopcExtents Reader::ReadCopcExtentsVlr(std::map &vlrs, { auto offset = FetchVlr(vlrs, "copc", 10000); auto extended_offset = FetchVlr(vlrs, "rock_robotic", 10001); - if (offset == 0) - throw std::runtime_error("Reader::ReadCopcExtentsVlr: No COPC Extents VLR found in file."); - - in_stream_->seekg(offset + lazperf::vlr_header::Size); - CopcExtents extents(las::CopcExtentsVlr::create(*in_stream_, static_cast(vlrs[offset].data_length)), - static_cast(reader_->header().point_format_id), - static_cast(eb_vlr.items.size()), extended_offset != 0); + if (offset != 0) + { + in_stream_->seekg(offset + lazperf::vlr_header::Size); + CopcExtents extents(las::CopcExtentsVlr::create(*in_stream_, static_cast(vlrs[offset].data_length)), + static_cast(reader_->header().point_format_id), + static_cast(eb_vlr.items.size()), extended_offset != 0); - // Load mean/var if they exist - if (extended_offset != 0) + // Load mean/var if they exist + if (extended_offset != 0) + { + in_stream_->seekg(extended_offset + lazperf::vlr_header::Size); + extents.SetExtendedStats( + las::CopcExtentsVlr::create(*in_stream_, static_cast(vlrs[extended_offset].data_length))); + } + return extents; + } + else { - in_stream_->seekg(extended_offset + lazperf::vlr_header::Size); - extents.SetExtendedStats( - las::CopcExtentsVlr::create(*in_stream_, static_cast(vlrs[extended_offset].data_length))); + return CopcExtents(reader_->header().point_format_id); } - return extents; } las::WktVlr Reader::ReadWktVlr(std::map &vlrs)