[Liblas-commits] laszip: updated error information via char* error_string

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Jun 13 08:53:43 EDT 2011


details:   http://hg.liblas.orglaszip/rev/e1dfec84177b
changeset: 238:e1dfec84177b
user:      isenburg
date:      Mon Jun 13 05:52:36 2011 -0700
description:
updated error information via char* error_string
Subject: laszip: updated error information via char* error_string

details:   http://hg.liblas.orglaszip/rev/a5d76cb1211e
changeset: 239:a5d76cb1211e
user:      isenburg
date:      Mon Jun 13 05:54:33 2011 -0700
description:
updated error information via char* error_string
Subject: laszip: improved GPS time compression

details:   http://hg.liblas.orglaszip/rev/a963ce4a03f9
changeset: 240:a963ce4a03f9
user:      isenburg
date:      Mon Jun 13 05:55:54 2011 -0700
description:
improved GPS time compression
Subject: laszip: updated usage example

details:   http://hg.liblas.orglaszip/rev/93b3dc9ecd89
changeset: 241:93b3dc9ecd89
user:      isenburg
date:      Mon Jun 13 05:56:51 2011 -0700
description:
updated usage example

diffstat:

 include/laszip/lasunzipper.hpp    |    8 +-
 include/laszip/laszip.hpp         |   44 ++--
 include/laszip/laszipper.hpp      |    8 +-
 src/lasreaditemcompressed_v2.cpp  |   66 +++---
 src/lasreadpoint.cpp              |    8 +-
 src/lasunzipper.cpp               |   46 ++--
 src/laswriteitemcompressed_v2.cpp |   84 +++-----
 src/laswritepoint.cpp             |    6 -
 src/laszip.cpp                    |  355 +++++++++++++++++++++----------------
 src/laszipper.cpp                 |   47 ++--
 src/mydefs.hpp                    |    8 +
 tools/laszippertest.cpp           |  109 ++++++----
 12 files changed, 416 insertions(+), 373 deletions(-)

diffs (truncated from 1496 to 300 lines):

diff -r 846198906775 -r 93b3dc9ecd89 include/laszip/lasunzipper.hpp
--- a/include/laszip/lasunzipper.hpp	Mon May 16 08:01:23 2011 -0700
+++ b/include/laszip/lasunzipper.hpp	Mon Jun 13 05:56:51 2011 -0700
@@ -51,17 +51,19 @@
 class LASZIP_DLL LASunzipper
 {
 public:
-  unsigned int open(FILE* file, const LASzip* laszip);
-  unsigned int open(istream& stream, const LASzip* laszip);
+  bool open(FILE* file, const LASzip* laszip);
+  bool open(istream& stream, const LASzip* laszip);
  
   unsigned int tell() const;
   bool seek(const unsigned int position);
   bool read(unsigned char * const * point);
-  unsigned int close();
+  bool close();
 
   LASunzipper();
   ~LASunzipper();
 
+  char* error_string;
+
 private:
   unsigned int count;
   ByteStreamIn* stream;
diff -r 846198906775 -r 93b3dc9ecd89 include/laszip/laszip.hpp
--- a/include/laszip/laszip.hpp	Mon May 16 08:01:23 2011 -0700
+++ b/include/laszip/laszip.hpp	Mon Jun 13 05:56:51 2011 -0700
@@ -50,44 +50,43 @@
 #define LASZIP_COMPRESSOR_NONE              0
 #define LASZIP_COMPRESSOR_POINTWISE         1
 #define LASZIP_COMPRESSOR_POINTWISE_CHUNKED 2
+#define LASZIP_COMPRESSOR_TOTAL_NUMBER_OF   3
 
 #define LASZIP_COMPRESSOR_DEFAULT LASZIP_COMPRESSOR_POINTWISE
 #define LASZIP_COMPRESSOR_CHUNKED LASZIP_COMPRESSOR_POINTWISE_CHUNKED
 
 #define LASZIP_CODER_ARITHMETIC             0
+#define LASZIP_CODER_TOTAL_NUMBER_OF        1
 
-#define LASZIP_CHUNK_SIZE_DEFAULT 50000
+#define LASZIP_CHUNK_SIZE_DEFAULT           50000
 
 #include "laszipexport.hpp"
 
-class LASZIP_DLL LASitem
+class LASitem
 {
 public:
   enum Type { BYTE = 0, SHORT, INT, LONG, FLOAT, DOUBLE, POINT10, GPSTIME11, RGB12, WAVEPACKET13 } type;
   unsigned short size;
   unsigned short version;
-
-  // number parameter only used when setting to BYTE
   bool is_type(LASitem::Type t) const;
-  bool supported() const;
-
   const char* get_name() const;
-
-  // back and forth between item array and point type and size
-  bool setup(unsigned short* num_items, LASitem** items, const unsigned char point_type, const unsigned short point_size, const unsigned short compressor=LASZIP_COMPRESSOR_NONE) const;
-  bool is_standard(const unsigned short num_items, const LASitem* items, unsigned char* point_type=0, unsigned short* record_length=0) const;
-
-  // version control
-  bool request_version(unsigned short num_items, LASitem* items, const unsigned short compressor, const unsigned short requested_version) const;
-  bool request_version(const unsigned short compressor, const unsigned short requested_version);
 };
 
 class LASZIP_DLL LASzip
 {
 public:
 
-  LASzip();
-  ~LASzip();
+  // supported version control
+  bool check_compressor(const unsigned short compressor);
+  bool check_coder(const unsigned short coder);
+  bool check_item(const LASitem* item);
+  bool check_items(const unsigned short num_items, const LASitem* items);
+  bool check();
+
+  // go back and forth between item array and point type & size
+  bool setup(unsigned short* num_items, LASitem** items, const unsigned char point_type, const unsigned short point_size, const unsigned short compressor=LASZIP_COMPRESSOR_NONE);
+  bool is_standard(const unsigned short num_items, const LASitem* items, unsigned char* point_type=0, unsigned short* record_length=0) const;
+  bool is_standard(unsigned char* point_type=0, unsigned short* record_length=0) const;
 
   // pack to and unpack from VLR
   unsigned char* bytes;
@@ -97,11 +96,8 @@
   // setup
   bool setup(const unsigned char point_type, const unsigned short point_size, const unsigned short compressor=LASZIP_COMPRESSOR_DEFAULT);
   bool setup(const unsigned short num_items, const LASitem* items, const unsigned short compressor=LASZIP_COMPRESSOR_DEFAULT);
-  bool set_chunk_size(const unsigned int chunk_size);
-  bool request_version(const unsigned short requested_version);
-
-  // query point type and size
-  bool is_standard(unsigned char* point_type=0, unsigned short* record_length=0) const;
+  bool set_chunk_size(const unsigned int chunk_size);             /* for compressor only */
+  bool request_version(const unsigned short requested_version);   /* for compressor only */
 
   // stored in LASzip VLR data section
   unsigned short compressor;
@@ -115,6 +111,12 @@
   SIGNED_INT64 num_bytes;   /* not mandatory ... -1 if unknown */
   unsigned short num_items;
   LASitem* items;
+
+  LASzip();
+  ~LASzip();
+
+  bool return_error(const char* err);
+  char* error_string;
 };
 
 #endif
diff -r 846198906775 -r 93b3dc9ecd89 include/laszip/laszipper.hpp
--- a/include/laszip/laszipper.hpp	Mon May 16 08:01:23 2011 -0700
+++ b/include/laszip/laszipper.hpp	Mon Jun 13 05:56:51 2011 -0700
@@ -52,16 +52,18 @@
 class LASZIP_DLL LASzipper
 {
 public:
-  unsigned int open(FILE* outfile, const LASzip* laszip);
-  unsigned int open(ostream& outstream, const LASzip* laszip);
+  bool open(FILE* outfile, const LASzip* laszip);
+  bool open(ostream& outstream, const LASzip* laszip);
 
   bool write(const unsigned char* const * point);
   bool chunk();
-  unsigned int close();
+  bool close();
 
   LASzipper();
   ~LASzipper();
 
+  char* error_string;
+
 private:
   unsigned int count;
   ByteStreamOut* stream;
diff -r 846198906775 -r 93b3dc9ecd89 src/lasreaditemcompressed_v2.cpp
--- a/src/lasreaditemcompressed_v2.cpp	Mon May 16 08:01:23 2011 -0700
+++ b/src/lasreaditemcompressed_v2.cpp	Mon Jun 13 05:56:51 2011 -0700
@@ -241,17 +241,11 @@
 */
 
 #define LASZIP_GPSTIME_MULTI 500
-#define LASZIP_GPSTIME_MULTI_1024 (LASZIP_GPSTIME_MULTI + 0)
-#define LASZIP_GPSTIME_MULTI_2048 (LASZIP_GPSTIME_MULTI + 1)
-#define LASZIP_GPSTIME_MULTI_4096 (LASZIP_GPSTIME_MULTI + 2)
-#define LASZIP_GPSTIME_MULTI_MINUS_11000 (LASZIP_GPSTIME_MULTI + 3)
-#define LASZIP_GPSTIME_MULTI_MINUS_5500 (LASZIP_GPSTIME_MULTI + 4)
-#define LASZIP_GPSTIME_MULTI_MINUS_550 (LASZIP_GPSTIME_MULTI + 5)
-#define LASZIP_GPSTIME_MULTI_MINUS_55 (LASZIP_GPSTIME_MULTI + 6)
-#define LASZIP_GPSTIME_MULTI_UNCHANGED (LASZIP_GPSTIME_MULTI + 17)
-#define LASZIP_GPSTIME_MULTI_DOUBLE (LASZIP_GPSTIME_MULTI + 18)
+#define LASZIP_GPSTIME_MULTI_MINUS -10
+#define LASZIP_GPSTIME_MULTI_UNCHANGED (LASZIP_GPSTIME_MULTI - LASZIP_GPSTIME_MULTI_MINUS + 1)
+#define LASZIP_GPSTIME_MULTI_CODE_FULL (LASZIP_GPSTIME_MULTI - LASZIP_GPSTIME_MULTI_MINUS + 2)
 
-#define LASZIP_GPSTIME_MULTI_TOTAL (LASZIP_GPSTIME_MULTI + 22) 
+#define LASZIP_GPSTIME_MULTI_TOTAL (LASZIP_GPSTIME_MULTI - LASZIP_GPSTIME_MULTI_MINUS + 6) 
 
 LASreadItemCompressed_GPSTIME11_v2::LASreadItemCompressed_GPSTIME11_v2(EntropyDecoder* dec)
 {
@@ -261,7 +255,7 @@
   /* create entropy models and integer compressors */
   m_gpstime_multi = dec->createSymbolModel(LASZIP_GPSTIME_MULTI_TOTAL);
   m_gpstime_0diff = dec->createSymbolModel(6);
-  ic_gpstime = new IntegerCompressor(dec, 32, 7); // 32 bits, 7 contexts
+  ic_gpstime = new IntegerCompressor(dec, 32, 9); // 32 bits, 9 contexts
 }
 
 LASreadItemCompressed_GPSTIME11_v2::~LASreadItemCompressed_GPSTIME11_v2()
@@ -312,10 +306,12 @@
     else if (multi == 2) // the difference is huge
     {
       next = (next+1)&3;
+      last_gpstime[next].u64 = ic_gpstime->decompress((I32)(last_gpstime[last].u64 >> 32), 8);
+      last_gpstime[next].u64 = last_gpstime[next].u64 << 32;
+      last_gpstime[next].u64 |= dec->readInt();
       last = next;
       last_gpstime_diff[last] = 0;
       multi_extreme_counter[last] = 0; 
-      last_gpstime[last].u64 = dec->readInt64();
     }
     else if (multi > 2) // we switch to another sequence
     {
@@ -336,7 +332,7 @@
       I32 gpstime_diff;
       if (multi == 0)
       {
-        gpstime_diff = ic_gpstime->decompress(0, 6);
+        gpstime_diff = ic_gpstime->decompress(0, 7);
         multi_extreme_counter[last]++;
         if (multi_extreme_counter[last] > 3)
         {
@@ -351,15 +347,9 @@
         else
           gpstime_diff = ic_gpstime->decompress(multi*last_gpstime_diff[last], 3);
       }
-      else if (multi < LASZIP_GPSTIME_MULTI_MINUS_11000)
+      else if (multi == LASZIP_GPSTIME_MULTI)
       {
-        if (multi == LASZIP_GPSTIME_MULTI_1024)
-          multi = 1024;
-        else if (multi == LASZIP_GPSTIME_MULTI_2048)
-          multi = 2048;
-        else
-          multi = 4096;
-        gpstime_diff = ic_gpstime->decompress(multi*last_gpstime_diff[last], 4);
+        gpstime_diff = ic_gpstime->decompress(LASZIP_GPSTIME_MULTI*last_gpstime_diff[last], 4);
         multi_extreme_counter[last]++;
         if (multi_extreme_counter[last] > 3)
         {
@@ -369,31 +359,37 @@
       }
       else
       {
-        if (multi == LASZIP_GPSTIME_MULTI_MINUS_11000)
-          multi = -11000;
-        else if (multi == LASZIP_GPSTIME_MULTI_MINUS_5500)
-          multi = -5500;
-        else if (multi == LASZIP_GPSTIME_MULTI_MINUS_550)
-          multi = -550;
-        else if (multi == LASZIP_GPSTIME_MULTI_MINUS_55)
-          multi = -55;
+        multi = LASZIP_GPSTIME_MULTI - multi;
+        if (multi > LASZIP_GPSTIME_MULTI_MINUS)
+        {
+          gpstime_diff = ic_gpstime->decompress(multi*last_gpstime_diff[last], 5);
+        }
         else
-          multi = LASZIP_GPSTIME_MULTI_MINUS_55-multi;
-        gpstime_diff = ic_gpstime->decompress(multi*last_gpstime_diff[last], 5);
+        {
+          gpstime_diff = ic_gpstime->decompress(LASZIP_GPSTIME_MULTI_MINUS*last_gpstime_diff[last], 6);
+          multi_extreme_counter[last]++;
+          if (multi_extreme_counter[last] > 3)
+          {
+            last_gpstime_diff[last] = gpstime_diff;
+            multi_extreme_counter[last] = 0;
+          }
+        }
       }
       last_gpstime[last].i64 += gpstime_diff;
     }
-    else if (multi ==  LASZIP_GPSTIME_MULTI_DOUBLE)
+    else if (multi ==  LASZIP_GPSTIME_MULTI_CODE_FULL)
     {
       next = (next+1)&3;
+      last_gpstime[next].u64 = ic_gpstime->decompress((I32)(last_gpstime[last].u64 >> 32), 8);
+      last_gpstime[next].u64 = last_gpstime[next].u64 << 32;
+      last_gpstime[next].u64 |= dec->readInt();
       last = next;
       last_gpstime_diff[last] = 0;
       multi_extreme_counter[last] = 0; 
-      last_gpstime[last].u64 = dec->readInt64();
     }
-    else if (multi >=  LASZIP_GPSTIME_MULTI_DOUBLE)
+    else if (multi >=  LASZIP_GPSTIME_MULTI_CODE_FULL)
     {
-      last = (last+multi-LASZIP_GPSTIME_MULTI_DOUBLE)&3;
+      last = (last+multi-LASZIP_GPSTIME_MULTI_CODE_FULL)&3;
       return read(item);
     }
   }
diff -r 846198906775 -r 93b3dc9ecd89 src/lasreadpoint.cpp
--- a/src/lasreadpoint.cpp	Mon May 16 08:01:23 2011 -0700
+++ b/src/lasreadpoint.cpp	Mon Jun 13 05:56:51 2011 -0700
@@ -69,12 +69,6 @@
     if (items != laszip->items) return FALSE;
   }
 
-  // check if we support the items
-  for (i = 0; i < num_items; i++)
-  {
-    if (!items[i].supported()) return FALSE;
-  }
-
   // create entropy decoder (if requested)
   dec = 0;
   if (laszip && laszip->compressor)
@@ -342,7 +336,7 @@
 {
   if (readers == readers_compressed)
   {
-    dec->done();
+    if (dec) dec->done();
   }
   return TRUE;
 }
diff -r 846198906775 -r 93b3dc9ecd89 src/lasunzipper.cpp
--- a/src/lasunzipper.cpp	Mon May 16 08:01:23 2011 -0700
+++ b/src/lasunzipper.cpp	Mon Jun 13 05:56:51 2011 -0700
@@ -30,46 +30,48 @@
 */
 #include "lasunzipper.hpp"
 


More information about the Liblas-commits mailing list