[Liblas-commits] hg: Fix VLR size bug for instances where so many points occupy s...

liblas-commits at liblas.org liblas-commits at liblas.org
Mon May 16 19:17:27 EDT 2011


details:   http://hg.liblas.orghg/rev/46289289a279
changeset: 2944:46289289a279
user:      Gary Huber <gary at garyhuberart.com>
date:      Mon May 16 17:15:30 2011 -0600
description:
Fix VLR size bug for instances where so many points occupy such a small space that their index cell overflows a single VLR size limitation.
Subject: hg: Allow array resizing without throwing out of range exception for instances where so many points occupy such a small space that their index cell overflows a single VLR size limitation.

details:   http://hg.liblas.orghg/rev/9c6418b585c3
changeset: 2945:9c6418b585c3
user:      Gary Huber <gary at garyhuberart.com>
date:      Mon May 16 17:16:31 2011 -0600
description:
Allow array resizing without throwing out of range exception for instances where so many points occupy such a small space that their index cell overflows a single VLR size limitation.

diffstat:

 include/liblas/detail/index/indexoutput.hpp |  8 ++++----
 src/detail/index/indexoutput.cpp            |  2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diffs (51 lines):

diff -r 993d198e47e0 -r 9c6418b585c3 include/liblas/detail/index/indexoutput.hpp
--- a/include/liblas/detail/index/indexoutput.hpp	Mon May 16 12:25:23 2011 -0700
+++ b/include/liblas/detail/index/indexoutput.hpp	Mon May 16 17:16:31 2011 -0600
@@ -77,7 +77,7 @@
     LIBLAS_SWAP_BYTES_N(src, sizeof(T));
     // error if writing past array end
     if (static_cast<size_t>(pos) + sizeof(T) > dest.size())
-        throw std::out_of_range("liblas::detail::WriteVLRData_n: array index out of range");
+        dest.resize(dest.size() + (std::numeric_limits<unsigned short>::max)());
     // copy sizeof(T) bytes to destination
     memcpy(&dest[pos], &src, sizeof(T));
     // increment the write position to end of written data
@@ -91,7 +91,7 @@
     LIBLAS_SWAP_BYTES_N(src, sizeof(T));
     // error if writing past array end
     if (static_cast<size_t>(pos) + sizeof(T) > dest.size())
-        throw std::out_of_range("liblas::detail::WriteVLRDataNoInc_n: array index out of range");
+        dest.resize(dest.size() + (std::numeric_limits<unsigned short>::max)());
     // copy sizeof(T) bytes to destination
     memcpy(&dest[pos], &src, sizeof(T));
 }
@@ -103,7 +103,7 @@
     std::memcpy(&dest[pos], src, srclen);
     // error if writing past array end
     if (static_cast<size_t>(pos) + static_cast<size_t>(srclen) > dest.size())
-        throw std::out_of_range("liblas::detail::WriteVLRData_str: array index out of range");
+        dest.resize(dest.size() + (std::numeric_limits<unsigned short>::max)());
     // increment the write position to end of written data
     pos += srclen;
 }
@@ -113,7 +113,7 @@
 {
     // error if writing past array end
     if (static_cast<size_t>(pos) + static_cast<size_t>(srclen) > dest.size())
-        throw std::out_of_range("liblas::detail::WriteVLRDataNoInc_str: array index out of range");
+        dest.resize(dest.size() + (std::numeric_limits<unsigned short>::max)());
     // copy srclen bytes to destination
     memcpy(&dest[pos], src, srclen);
 }
diff -r 993d198e47e0 -r 9c6418b585c3 src/detail/index/indexoutput.cpp
--- a/src/detail/index/indexoutput.cpp	Mon May 16 12:25:23 2011 -0700
+++ b/src/detail/index/indexoutput.cpp	Mon May 16 17:16:31 2011 -0600
@@ -295,7 +295,7 @@
 				boost::uint32_t WritePos = m_DataRecordSize;
 				// m_TempWritePos is the size of the new data block
 				// m_DataRecordSize is amount of common data written already
-				boost::uint32_t UnwrittenBytes = m_TempWritePos + m_DataRecordSize;
+				boost::uint32_t UnwrittenBytes = m_TempWritePos;
 				// Make DataRecordSize equal to the total size of the data + common data 
 				m_DataRecordSize += m_TempWritePos;
 				// write the total size in the common data section


More information about the Liblas-commits mailing list