From eb35d1adc2cca1c2a9cafd4e57c979378e596abc Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Sun, 20 Jul 2014 20:37:48 -0500 Subject: [PATCH] don't do fancy non-working magic to try to calculate a point count for files in append mode #48 --- src/detail/writer/header.cpp | 25 ++----------------------- src/detail/writer/writer.cpp | 4 ++-- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/src/detail/writer/header.cpp b/src/detail/writer/header.cpp index d7396ef74..db9297124 100644 --- a/src/detail/writer/header.cpp +++ b/src/detail/writer/header.cpp @@ -100,35 +100,14 @@ void Header::write() // If we are in append mode, we are not touching *any* VLRs. if (bAppendMode) { - // We're opened in append mode - - if (!m_header.Compressed()) - { - ios::off_type points = end - static_cast(m_header.GetDataOffset()); - ios::off_type count = points / static_cast(m_header.GetDataRecordLength()); - - if (points < 0) { - std::ostringstream oss; - oss << "The header's data offset, " << m_header.GetDataOffset() - <<", is much larger than the size of the file, " << end - <<", and something is amiss. Did you use the right header" - <<" offset value?"; - throw std::runtime_error(oss.str()); - } - - m_pointCount = static_cast(count); - - } else { - m_pointCount = m_header.GetPointRecordsCount(); - } + // Believe the header + m_pointCount = m_header.GetPointRecordsCount(); // Position to the beginning of the file to start writing the header m_ofs.seekp(0, ios::beg); - } else { - // Rewrite the georeference VLR entries if they exist m_header.DeleteVLRs("liblas", 2112); m_header.SetGeoreference(); diff --git a/src/detail/writer/writer.cpp b/src/detail/writer/writer.cpp index 441081e5b..686a9cfa6 100644 --- a/src/detail/writer/writer.cpp +++ b/src/detail/writer/writer.cpp @@ -77,7 +77,7 @@ void WriterImpl::UpdatePointCount(boost::uint32_t count) boost::uint32_t out = m_pointCount; if ( count != 0 ) { out = count; } - + m_header->SetPointRecordsCount(out); if (!m_ofs.good() ) return; @@ -102,7 +102,7 @@ WriterImpl::~WriterImpl() // care if we weren't able to write it. try { - UpdatePointCount(0); + UpdatePointCount(m_pointCount); } catch (std::runtime_error const&) {