[Liblas-commits] hg: use bits 7 and 6 for laszip flags (as per Martin)

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Jan 3 13:59:34 EST 2011


details:   http://hg.liblas.orghg/rev/e2cf1be6b142
changeset: 2673:e2cf1be6b142
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Jan 03 10:59:15 2011 -0800
description:
use bits 7 and 6 for laszip flags (as per Martin)

diffstat:

 src/detail/reader/header.cpp |  15 +++++++++++++--
 src/detail/writer/header.cpp |   2 +-
 2 files changed, 14 insertions(+), 3 deletions(-)

diffs (41 lines):

diff -r 5fae42ddbc14 -r e2cf1be6b142 src/detail/reader/header.cpp
--- a/src/detail/reader/header.cpp	Mon Jan 03 10:35:29 2011 -0800
+++ b/src/detail/reader/header.cpp	Mon Jan 03 10:59:15 2011 -0800
@@ -161,12 +161,23 @@
     // 17. Point Data Format ID
     read_n(n1, m_ifs, sizeof(n1));
 
-    if (n1 >> 7)
+    // the high two bits are reserved for laszip compression type
+    uint8_t compression_bits = (n1 & 0xC0) >> 6;
+    if (compression_bits == 0)
+    {
+        m_header->SetCompressed(false);
+    }
+    else if (compression_bits == 2)
     {
         m_header->SetCompressed(true);
-        n1 &= 0x7f;
+    }
+    else
+    {
+        throw std::domain_error("invalid point compression format");
     }
 
+    // strip the hgih bits, to determine point type
+    n1 &= 0x3f;
     if (n1 == liblas::ePointFormat0)
     {
         m_header->SetDataFormatId(liblas::ePointFormat0);
diff -r 5fae42ddbc14 -r e2cf1be6b142 src/detail/writer/header.cpp
--- a/src/detail/writer/header.cpp	Mon Jan 03 10:35:29 2011 -0800
+++ b/src/detail/writer/header.cpp	Mon Jan 03 10:59:15 2011 -0800
@@ -237,7 +237,7 @@
     // 16. Point Data Format ID
     n1 = static_cast<uint8_t>(m_header.GetDataFormatId());
     uint8_t n1tmp = n1;
-    if (m_header.Compressed())
+    if (m_header.Compressed()) // high bit set indicates laszip compression
         n1tmp |= 0x80;
     detail::write_n(m_ofs, n1tmp, sizeof(n1tmp));
 


More information about the Liblas-commits mailing list