[Liblas-commits] hg: Use the m_zipPoint's LASzip instead of one on the writer

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Jun 27 15:05:00 EDT 2011


details:   http://hg.liblas.orghg/rev/a2f492012245
changeset: 3022:a2f492012245
user:      Howard Butler <hobu.inc at gmail.com>
date:      Mon Jun 27 14:04:52 2011 -0500
description:
Use the m_zipPoint's LASzip instead of one on the writer

diffstat:

 include/liblas/detail/writer/zipwriter.hpp |   1 -
 include/liblas/detail/zippoint.hpp         |   2 ++
 src/detail/writer/zipwriter.cpp            |  22 ++++++++--------------
 3 files changed, 10 insertions(+), 15 deletions(-)

diffs (103 lines):

diff -r 73bc7006a148 -r a2f492012245 include/liblas/detail/writer/zipwriter.hpp
--- a/include/liblas/detail/writer/zipwriter.hpp	Mon Jun 27 12:29:38 2011 -0500
+++ b/include/liblas/detail/writer/zipwriter.hpp	Mon Jun 27 14:04:52 2011 -0500
@@ -99,7 +99,6 @@
 private:
     boost::uint32_t m_pointCount;
 
-    boost::scoped_ptr<LASzip> m_zip;
     boost::scoped_ptr<LASzipper> m_zipper;
     boost::scoped_ptr<ZipPoint> m_zipPoint;
     
diff -r 73bc7006a148 -r a2f492012245 include/liblas/detail/zippoint.hpp
--- a/include/liblas/detail/zippoint.hpp	Mon Jun 27 12:29:38 2011 -0500
+++ b/include/liblas/detail/zippoint.hpp	Mon Jun 27 14:04:52 2011 -0500
@@ -73,6 +73,8 @@
     bool ValidateVLR(const VariableRecord& vlr) const;
     
     bool IsZipVLR(const VariableRecord& vlr) const;
+    
+    LASzip* GetZipper() const { return m_zip.get(); }
 
 private:
     void ConstructItems(unsigned char, unsigned short);
diff -r 73bc7006a148 -r a2f492012245 src/detail/writer/zipwriter.cpp
--- a/src/detail/writer/zipwriter.cpp	Mon Jun 27 12:29:38 2011 -0500
+++ b/src/detail/writer/zipwriter.cpp	Mon Jun 27 14:04:52 2011 -0500
@@ -64,7 +64,6 @@
     //m_point_writer(PointWriterPtr( )), 
     m_header_writer(HeaderWriterPtr()), 
     m_pointCount(0),
-    m_zip(NULL),
     m_zipper(NULL),
     m_zipPoint(NULL)
 {
@@ -101,12 +100,8 @@
 
 void ZipWriterImpl::WritePoint(liblas::Point const& point)
 {
-    if (!m_zip)
+    if (!m_zipPoint)
     {
-        // Initialize a scoped_ptr and swap it with our member variable 
-        // that will contain it.
-        boost::scoped_ptr<LASzip> s(new LASzip());
-        m_zip.swap(s);
             
         PointFormatName format = m_header->GetDataFormatId();
 
@@ -114,19 +109,19 @@
         m_zipPoint.swap(z);
         
         bool ok = false;
-        ok = m_zip->setup((unsigned char)format, m_header->GetDataRecordLength());
+        ok = m_zipPoint->GetZipper()->setup((unsigned char)format, m_header->GetDataRecordLength());
         if (!ok)
         {
             std::ostringstream oss;
-            oss << "Error opening compression core: " << std::string(m_zip->get_error());
+            oss << "Error opening compression core: " << std::string(m_zipPoint->GetZipper()->get_error());
             throw liblas_error(oss.str());
         }
 
-        ok = m_zip->pack(m_zipPoint->his_vlr_data, m_zipPoint->his_vlr_num);
+        ok = m_zipPoint->GetZipper()->pack(m_zipPoint->his_vlr_data, m_zipPoint->his_vlr_num);
         if (!ok)
         {
             std::ostringstream oss;
-            oss << "Error packing VLR data for compression: " << std::string(m_zip->get_error());
+            oss << "Error packing VLR data for compression: " << std::string(m_zipPoint->GetZipper()->get_error());
             throw liblas_error(oss.str());
         }
     }
@@ -138,11 +133,11 @@
 
         bool stat(false);
 
-        stat = m_zipper->open(m_ofs, m_zip.get());
+        stat = m_zipper->open(m_ofs, m_zipPoint->GetZipper());
         if (!stat)
         {
             std::ostringstream oss;
-            oss << "Error opening LASzipper: " << std::string(m_zip->get_error());
+            oss << "Error opening LASzipper: " << std::string(m_zipPoint->GetZipper()->get_error());
             throw liblas_error(oss.str());
         }
     }
@@ -162,7 +157,7 @@
     if (!ok)
     {
         std::ostringstream oss;
-        oss << "Error writing compressed point data: " << std::string(m_zip->get_error());
+        oss << "Error writing compressed point data: " << std::string(m_zipper->get_error());
         throw liblas_error(oss.str());
     }
     ++m_pointCount;
@@ -182,7 +177,6 @@
     }
 
     m_zipPoint.reset();
-    m_zip.reset();
     m_zipper.reset();
 
 }


More information about the Liblas-commits mailing list