[Liblas-commits] laszip: further clean-up and commenting

liblas-commits at liblas.org liblas-commits at liblas.org
Tue May 10 07:59:49 EDT 2011


details:   http://hg.liblas.orglaszip/rev/5463dc970bea
changeset: 227:5463dc970bea
user:      isenburg
date:      Tue May 10 04:59:03 2011 -0700
description:
further clean-up and commenting
Subject: laszip: moved all version control into LASzip

details:   http://hg.liblas.orglaszip/rev/24d2c0bb7bb1
changeset: 228:24d2c0bb7bb1
user:      isenburg
date:      Tue May 10 05:00:26 2011 -0700
description:
moved all version control into LASzip
Subject: laszip: moved all version control into LASzip

details:   http://hg.liblas.orglaszip/rev/3425d6d1191f
changeset: 229:3425d6d1191f
user:      isenburg
date:      Tue May 10 05:00:51 2011 -0700
description:
moved all version control into LASzip
Subject: laszip: moved all version control into LASzip

details:   http://hg.liblas.orglaszip/rev/4691ad3179a3
changeset: 230:4691ad3179a3
user:      isenburg
date:      Tue May 10 05:01:55 2011 -0700
description:
moved all version control into LASzip

diffstat:

 include/laszip/lasunzipper.hpp |   7 +-
 include/laszip/laszip.hpp      |  14 +++---
 include/laszip/laszipper.hpp   |   6 +-
 src/lasreadpoint.cpp           |   7 +++
 src/lasunzipper.cpp            |  23 ++++++---
 src/laswritepoint.cpp          |  98 ++++++++++++++++++-----------------------
 src/laswritepoint.hpp          |   2 +-
 src/laszip.cpp                 |  78 ++++++++++++++++++++++++++++-----
 src/laszipper.cpp              |  17 +++---
 tools/laszippertest.cpp        |  91 ++++++++++++++++++++++----------------
 10 files changed, 206 insertions(+), 137 deletions(-)

diffs (truncated from 644 to 300 lines):

diff -r 49a4c9dee1c5 -r 4691ad3179a3 include/laszip/lasunzipper.hpp
--- a/include/laszip/lasunzipper.hpp	Mon May 09 16:28:19 2011 -0700
+++ b/include/laszip/lasunzipper.hpp	Tue May 10 05:01:55 2011 -0700
@@ -51,9 +51,10 @@
 class LASZIP_DLL LASunzipper
 {
 public:
-  unsigned int setup(const LASzip* laszip);
-  unsigned int open(FILE* file);
-  unsigned int open(istream& stream);
+  unsigned int open(FILE* file, const LASzip* laszip);
+  unsigned int 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();
diff -r 49a4c9dee1c5 -r 4691ad3179a3 include/laszip/laszip.hpp
--- a/include/laszip/laszip.hpp	Mon May 09 16:28:19 2011 -0700
+++ b/include/laszip/laszip.hpp	Tue May 10 05:01:55 2011 -0700
@@ -68,15 +68,18 @@
   unsigned short version;
 
   // number parameter only used when setting to BYTE
-  void set(LASitem::Type t, unsigned short number=1);
   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(const unsigned char point_type, const unsigned short point_size, unsigned short* num_items, LASitem** items) const;
+  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
@@ -94,8 +97,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);
-  void set_chunk_size(const unsigned int chunk_size);
-  void request_version(const unsigned int requested_version);
+  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;
@@ -112,9 +115,6 @@
   SIGNED_INT64 num_bytes;   /* not mandatory ... -1 if unknown */
   unsigned short num_items;
   LASitem* items;
-
-  // not stored LASzip VLR data section
-  unsigned short requested_version;
 };
 
 #endif
diff -r 49a4c9dee1c5 -r 4691ad3179a3 include/laszip/laszipper.hpp
--- a/include/laszip/laszipper.hpp	Mon May 09 16:28:19 2011 -0700
+++ b/include/laszip/laszipper.hpp	Tue May 10 05:01:55 2011 -0700
@@ -52,9 +52,9 @@
 class LASZIP_DLL LASzipper
 {
 public:
-  unsigned int setup(LASzip* laszip);
-  unsigned int open(FILE* outfile);
-  unsigned int open(ostream& outstream);
+  unsigned int open(FILE* outfile, const LASzip* laszip);
+  unsigned int open(ostream& outstream, const LASzip* laszip);
+
   bool write(const unsigned char* const * point);
   bool chunk();
   unsigned int close();
diff -r 49a4c9dee1c5 -r 4691ad3179a3 src/lasreadpoint.cpp
--- a/src/lasreadpoint.cpp	Mon May 09 16:28:19 2011 -0700
+++ b/src/lasreadpoint.cpp	Tue May 10 05:01:55 2011 -0700
@@ -62,6 +62,13 @@
 {
   U32 i;
 
+  // is laszip exists then we must use its items
+  if (laszip)
+  {
+    if (num_items != laszip->num_items) return FALSE;
+    if (items != laszip->items) return FALSE;
+  }
+
   // check if we support the items
   for (i = 0; i < num_items; i++)
   {
diff -r 49a4c9dee1c5 -r 4691ad3179a3 src/lasunzipper.cpp
--- a/src/lasunzipper.cpp	Mon May 09 16:28:19 2011 -0700
+++ b/src/lasunzipper.cpp	Tue May 10 05:01:55 2011 -0700
@@ -34,21 +34,16 @@
 #include "bytestreamin_istream.hpp"
 #include "lasreadpoint.hpp"
 
-unsigned int LASunzipper::setup(const LASzip* laszip)
+
+unsigned int LASunzipper::open(FILE* infile, const LASzip* laszip)
 {
+  if (!infile) return 1;
   if (!laszip) return 1;
   count = 0;
   if (reader) delete reader;
   reader = new LASreadPoint();
   if (!reader) return 1;
   if (!reader->setup(laszip->num_items, laszip->items, laszip)) return 1;
-  return 0;
-}
-
-unsigned int LASunzipper::open(FILE* infile)
-{
-  if (!infile) return 1;
-  if (!reader) return 1;
   if (stream) delete stream;
   if (IS_LITTLE_ENDIAN())
     stream = new ByteStreamInFileLE(infile);
@@ -59,9 +54,14 @@
   return 0;
 }
 
-unsigned int LASunzipper::open(istream& instream)
+unsigned int LASunzipper::open(istream& instream, const LASzip* laszip)
 {
+  if (!laszip) return 1;
+  count = 0;
+  if (reader) delete reader;
+  reader = new LASreadPoint();
   if (!reader) return 1;
+  if (!reader->setup(laszip->num_items, laszip->items, laszip)) return 1;
   if (stream) delete stream;
   if (IS_LITTLE_ENDIAN())
     stream = new ByteStreamInIstreamLE(instream);
@@ -82,6 +82,11 @@
   return false;
 }
 
+unsigned int LASunzipper::tell() const
+{
+  return count;
+}
+
 bool LASunzipper::read(unsigned char * const * point)
 {
   count++;
diff -r 49a4c9dee1c5 -r 4691ad3179a3 src/laswritepoint.cpp
--- a/src/laswritepoint.cpp	Mon May 09 16:28:19 2011 -0700
+++ b/src/laswritepoint.cpp	Tue May 10 05:01:55 2011 -0700
@@ -58,10 +58,17 @@
   chunk_start_position = 0;
 }
 
-BOOL LASwritePoint::setup(const U32 num_items, const LASitem* items, LASzip* laszip)
+BOOL LASwritePoint::setup(const U32 num_items, const LASitem* items, const LASzip* laszip)
 {
   U32 i;
 
+  // is laszip exists then we must use its items
+  if (laszip)
+  {
+    if (num_items != laszip->num_items) return FALSE;
+    if (items != laszip->items) return FALSE;
+  }
+
   // check if we support the items
   for (i = 0; i < num_items; i++)
   {
@@ -126,73 +133,56 @@
     default:
       return FALSE;
     }
-    if (laszip) laszip->items[i].version = 0;
   }
 
   // if needed create the compressed writers and set versions
   if (enc)
   {
     writers_compressed = new LASwriteItem*[num_writers];
-    if (laszip->requested_version <= 1)
+    for (i = 0; i < num_writers; i++)
     {
-      for (i = 0; i < num_writers; i++)
+      switch (items[i].type)
       {
-        switch (items[i].type)
-        {
-        case LASitem::POINT10:
+      case LASitem::POINT10:
+        if (items[i].version == 1)
           writers_compressed[i] = new LASwriteItemCompressed_POINT10_v1(enc);
-          laszip->items[i].version = 1;
-          break;
-        case LASitem::GPSTIME11:
+        else if (items[i].version == 2)
+          writers_compressed[i] = new LASwriteItemCompressed_POINT10_v2(enc);
+        else
+          return FALSE;
+        break;
+      case LASitem::GPSTIME11:
+        if (items[i].version == 1)
           writers_compressed[i] = new LASwriteItemCompressed_GPSTIME11_v1(enc);
-          laszip->items[i].version = 1;
-          break;
-        case LASitem::RGB12:
+        else if (items[i].version == 2)
+          writers_compressed[i] = new LASwriteItemCompressed_GPSTIME11_v2(enc);
+        else
+          return FALSE;
+        break;
+      case LASitem::RGB12:
+        if (items[i].version == 1)
           writers_compressed[i] = new LASwriteItemCompressed_RGB12_v1(enc);
-          laszip->items[i].version = 1;
-          break;
-        case LASitem::WAVEPACKET13:
-          writers_compressed[i] = new LASwriteItemCompressed_WAVEPACKET13_v1(enc);
-          laszip->items[i].version = 1;
-          break;
-        case LASitem::BYTE:
-          writers_compressed[i] = new LASwriteItemCompressed_BYTE_v1(enc, items[i].size);
-          laszip->items[i].version = 1;
-          break;
-        default:
+        else if (items[i].version == 2)
+          writers_compressed[i] = new LASwriteItemCompressed_RGB12_v2(enc);
+        else
           return FALSE;
-        }
-      }
-    }
-    else
-    {
-      for (i = 0; i < num_writers; i++)
-      {
-        switch (items[i].type)
-        {
-        case LASitem::POINT10:
-          writers_compressed[i] = new LASwriteItemCompressed_POINT10_v2(enc);
-          laszip->items[i].version = 2;
-          break;
-        case LASitem::GPSTIME11:
-          writers_compressed[i] = new LASwriteItemCompressed_GPSTIME11_v2(enc);
-          laszip->items[i].version = 2;
-          break;
-        case LASitem::RGB12:
-          writers_compressed[i] = new LASwriteItemCompressed_RGB12_v2(enc);
-          laszip->items[i].version = 2;
-          break;
-        case LASitem::WAVEPACKET13:
-          writers_compressed[i] = new LASwriteItemCompressed_WAVEPACKET13_v1(enc);
-          laszip->items[i].version = 1;
-          break;
-        case LASitem::BYTE:
+        break;
+      case LASitem::WAVEPACKET13:
+        if (items[i].version == 1)
+         writers_compressed[i] = new LASwriteItemCompressed_WAVEPACKET13_v1(enc);
+        else
+          return FALSE;
+        break;
+      case LASitem::BYTE:
+        if (items[i].version == 1)
+         writers_compressed[i] = new LASwriteItemCompressed_BYTE_v1(enc, items[i].size);
+        else if (items[i].version == 2)
           writers_compressed[i] = new LASwriteItemCompressed_BYTE_v2(enc, items[i].size);
-          laszip->items[i].version = 2;
-          break;
-        default:
+        else
           return FALSE;
-        }
+        break;
+      default:
+        return FALSE;
       }
     }
     if (laszip->compressor == LASZIP_COMPRESSOR_POINTWISE_CHUNKED)
diff -r 49a4c9dee1c5 -r 4691ad3179a3 src/laswritepoint.hpp
--- a/src/laswritepoint.hpp	Mon May 09 16:28:19 2011 -0700
+++ b/src/laswritepoint.hpp	Tue May 10 05:01:55 2011 -0700
@@ -50,7 +50,7 @@
   ~LASwritePoint();
 
   // should only be called *once*
-  BOOL setup(const U32 num_items, const LASitem* items, LASzip* laszip);
+  BOOL setup(const U32 num_items, const LASitem* items, const LASzip* laszip=0);
 
   BOOL init(ByteStreamOut* outstream);
   BOOL write(const U8 * const * point);
diff -r 49a4c9dee1c5 -r 4691ad3179a3 src/laszip.cpp
--- a/src/laszip.cpp	Mon May 09 16:28:19 2011 -0700
+++ b/src/laszip.cpp	Tue May 10 05:01:55 2011 -0700
@@ -45,7 +45,6 @@
   num_points = -1;


More information about the Liblas-commits mailing list