Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make extents vlr optional. #110

Merged
merged 1 commit into from
Apr 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions cpp/src/io/copc_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,26 @@ CopcExtents Reader::ReadCopcExtentsVlr(std::map<uint64_t, las::VlrHeader> &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<int>(vlrs[offset].data_length)),
static_cast<int8_t>(reader_->header().point_format_id),
static_cast<uint16_t>(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<int>(vlrs[offset].data_length)),
static_cast<int8_t>(reader_->header().point_format_id),
static_cast<uint16_t>(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<int>(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<int>(vlrs[extended_offset].data_length)));
return CopcExtents(reader_->header().point_format_id);
}
return extents;
}

las::WktVlr Reader::ReadWktVlr(std::map<uint64_t, las::VlrHeader> &vlrs)
Expand Down