[Liblas-commits] hg: finish of laszip work

liblas-commits at liblas.org liblas-commits at liblas.org
Wed May 11 14:45:25 EDT 2011


details:   http://hg.liblas.orghg/rev/5ed84f7d6e69
changeset: 2938:5ed84f7d6e69
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Wed May 11 11:45:20 2011 -0700
description:
finish of laszip work

diffstat:

 include/liblas/detail/zippoint.hpp |  10 ++++++--
 src/detail/reader/zipreader.cpp    |  15 +++++++++++++-
 src/detail/writer/zipwriter.cpp    |  39 +++++++++----------------------------
 src/detail/zippoint.cpp            |  16 ++++++++------
 4 files changed, 40 insertions(+), 40 deletions(-)

diffs (159 lines):

diff -r 38919ae3cad4 -r 5ed84f7d6e69 include/liblas/detail/zippoint.hpp
--- a/include/liblas/detail/zippoint.hpp	Wed May 11 11:26:21 2011 -0700
+++ b/include/liblas/detail/zippoint.hpp	Wed May 11 11:45:20 2011 -0700
@@ -71,13 +71,17 @@
     
     bool IsZipVLR(const VariableRecord& vlr) const;
 
-    int vlr_num;
-    unsigned char* vlr_data;
-
 private:
     void ConstructItems(PointFormatName);
 
 public: // for now
+    // LASzip::pack() allocates/sets vlr_data and vlr_num for us, and deletes it for us  ["his"]
+    // LASzip::unpack() just reads from the vlr_data we give it (we allocate and delete)  ["our"]
+    int his_vlr_num;
+    unsigned char* his_vlr_data;
+    int our_vlr_num;
+    unsigned char* our_vlr_data;
+
     unsigned int m_num_items;
     LASitem* m_items;
     unsigned char** m_lz_point;
diff -r 38919ae3cad4 -r 5ed84f7d6e69 src/detail/reader/zipreader.cpp
--- a/src/detail/reader/zipreader.cpp	Wed May 11 11:26:21 2011 -0700
+++ b/src/detail/reader/zipreader.cpp	Wed May 11 11:45:20 2011 -0700
@@ -130,8 +130,21 @@
         bool ok = false;
         try
         {
+            ok = m_zip->setup((unsigned char)format, m_header->GetDataRecordLength());
+        }
+        catch(...)
+        {
+            throw liblas_error("Error opening compression core (3)");
+        }
+        if (!ok)
+        {
+            throw liblas_error("Error opening compression core (2)");
+        }
 
-            ok = m_zip->unpack(m_zipPoint->vlr_data, m_zipPoint->vlr_num);
+        try
+        {
+
+            ok = m_zip->unpack(m_zipPoint->our_vlr_data, m_zipPoint->our_vlr_num);
         }
         catch(...)
         {
diff -r 38919ae3cad4 -r 5ed84f7d6e69 src/detail/writer/zipwriter.cpp
--- a/src/detail/writer/zipwriter.cpp	Wed May 11 11:26:21 2011 -0700
+++ b/src/detail/writer/zipwriter.cpp	Wed May 11 11:45:20 2011 -0700
@@ -119,8 +119,7 @@
         bool ok = false;
         try
         {
-            //ok = m_zip->setup(m_zipPoint->m_num_items, m_zipPoint->m_items);
-            ok = m_zip->setup((int)format, m_header->GetDataRecordLength());
+            ok = m_zip->setup((unsigned char)format, m_header->GetDataRecordLength());
         }
         catch(...)
         {
@@ -130,9 +129,10 @@
         {
             throw liblas_error("Error opening compression core (2)");
         }
+
         try
         {
-            ok = m_zip->pack(m_zipPoint->vlr_data, m_zipPoint->vlr_num);
+            ok = m_zip->pack(m_zipPoint->his_vlr_data, m_zipPoint->his_vlr_num);
         }
         catch(...)
         {
@@ -173,35 +173,16 @@
     bool ok = false;
     try
     {
-        const std::vector<boost::uint8_t>* data;
-    
-        data = &point.GetData();
+        const std::vector<boost::uint8_t>* data = &point.GetData();
+        assert(data->size() == m_zipPoint->m_lz_point_size);
 
-        if (data->size() != m_zipPoint->m_lz_point_size)
+        for (unsigned int i=0; i<m_zipPoint->m_lz_point_size; i++)
         {
-            // We need to repack the data.  
-            liblas::Point p(point);
-            p.SetHeaderPtr(m_header);
-            data = &p.GetData();
-    //      m_zipPoint->m_lz_point_data = const_cast<unsigned char*>(&(data->front()));
-            for (unsigned int i=0; i<m_zipPoint->m_lz_point_size; i++)
-            {
-                m_zipPoint->m_lz_point_data[i] = data->at(i);
-                //printf("%d %d\n", v[i], i);
-            }
-            ok = m_zipper->write(m_zipPoint->m_lz_point);
-        } else 
-        {
-//          m_zipPoint->m_lz_point_data = const_cast<unsigned char*>(&(data->front()));
-            for (unsigned int i=0; i<m_zipPoint->m_lz_point_size; i++)
-            {
-                m_zipPoint->m_lz_point_data[i] = data->at(i);
-                //printf("%d %d\n", v[i], i);
-            }
+            m_zipPoint->m_lz_point_data[i] = data->at(i);
+            //printf("%d %d\n", v[i], i);
+        }
 
-            ok = m_zipper->write(m_zipPoint->m_lz_point);
-        }
-       
+        ok = m_zipper->write(m_zipPoint->m_lz_point);
     }
     catch(...)
     {
diff -r 38919ae3cad4 -r 5ed84f7d6e69 src/detail/zippoint.cpp
--- a/src/detail/zippoint.cpp	Wed May 11 11:26:21 2011 -0700
+++ b/src/detail/zippoint.cpp	Wed May 11 11:45:20 2011 -0700
@@ -62,8 +62,10 @@
 
 
 ZipPoint::ZipPoint(PointFormatName format, const std::vector<VariableRecord>& vlrs)
-    : vlr_num(0)
-    , vlr_data(0)
+    : his_vlr_num(0)
+    , his_vlr_data(0)
+    , our_vlr_num(0)
+    , our_vlr_data(0)
     , m_num_items(0)
     , m_items(NULL)
     , m_lz_point(NULL)
@@ -84,11 +86,11 @@
     }
     if (vlr)
     {
-        vlr_num = vlr->GetData().size();
-        vlr_data = new unsigned char[vlr_num];
-        for (int i=0; i<vlr_num; i++)
+        our_vlr_num = vlr->GetData().size();
+        our_vlr_data = new unsigned char[our_vlr_num];
+        for (int i=0; i<our_vlr_num; i++)
         {
-            vlr_data[i] = vlr->GetData()[i];
+            our_vlr_data[i] = vlr->GetData()[i];
         }
     }
 
@@ -104,7 +106,7 @@
     delete[] m_lz_point;
     delete[] m_lz_point_data;
 
-//    delete[] vlr_data;
+    delete[] our_vlr_data;
 
     return;
 }


More information about the Liblas-commits mailing list