[Liblas-commits] hg: lint

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Jan 5 12:53:25 EST 2011


details:   http://hg.liblas.orghg/rev/3b2b76560089
changeset: 2694:3b2b76560089
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Wed Jan 05 09:47:56 2011 -0800
description:
lint
Subject: hg: explicitly trap for older, unsup compression format

details:   http://hg.liblas.orghg/rev/40ff369258a4
changeset: 2695:40ff369258a4
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Wed Jan 05 09:53:16 2011 -0800
description:
explicitly trap for older, unsup compression format

diffstat:

 src/detail/reader/header.cpp    |  14 ++++++++++----
 src/detail/reader/zipreader.cpp |   2 --
 2 files changed, 10 insertions(+), 6 deletions(-)

diffs (47 lines):

diff -r 39ed39f578fe -r 40ff369258a4 src/detail/reader/header.cpp
--- a/src/detail/reader/header.cpp	Wed Jan 05 09:06:08 2011 -0800
+++ b/src/detail/reader/header.cpp	Wed Jan 05 09:53:16 2011 -0800
@@ -162,21 +162,27 @@
     read_n(n1, m_ifs, sizeof(n1));
 
     // the high two bits are reserved for laszip compression type
-    uint8_t compression_bits = (n1 & 0xC0) >> 6;
-    if (compression_bits == 0)
+    uint8_t compression_bit_7 = (n1 & 0x80) >> 7;
+    uint8_t compression_bit_6 = (n1 & 0x40) >> 6;
+    if (!compression_bit_7 && !compression_bit_6)
     {
         m_header->SetCompressed(false);
     }
-    else if (compression_bits == 2)
+    else if (compression_bit_7 && !compression_bit_6)
     {
         m_header->SetCompressed(true);
     }
+    else if (compression_bit_7 && compression_bit_6)
+    {
+        throw std::domain_error("This file was compressed with an earlier, experimental version of laszip; please contact 'martin.isenburg at gmail.com' for assistance.");
+    }
     else
     {
+        assert(!compression_bit_7 && compression_bit_6);
         throw std::domain_error("invalid point compression format");
     }
 
-    // strip the hgih bits, to determine point type
+    // strip the high bits, to determine point type
     n1 &= 0x3f;
     if (n1 == liblas::ePointFormat0)
     {
diff -r 39ed39f578fe -r 40ff369258a4 src/detail/reader/zipreader.cpp
--- a/src/detail/reader/zipreader.cpp	Wed Jan 05 09:06:08 2011 -0800
+++ b/src/detail/reader/zipreader.cpp	Wed Jan 05 09:53:16 2011 -0800
@@ -279,8 +279,6 @@
 // laszip doesn't support seeking, or any want to do a reset, so we do it manually instead
 void ZipReaderImpl::ResetUnzipper()
 {
-    PointFormatName format = m_header->GetDataFormatId();
-
     if (!m_unzipper)
         throw liblas_error("Error resetting uncompression engine (1)");
  


More information about the Liblas-commits mailing list