[Liblas-commits] hg: 5 new changesets

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Dec 15 11:54:23 EST 2010


changeset 0bda3b2272c6 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=0bda3b2272c6
summary: fix up writer's pimpl to update the point count when it is destroyed

changeset b5921bac99e7 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=b5921bac99e7
summary: fix up writer's pimpl to update the point count when it is destroyed

changeset 921a246eb843 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=921a246eb843
summary: remove inaccurate comment

changeset 18c978c079a7 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=18c978c079a7
summary: fix typo in help and block code in RewriteHeader to make sure that one stream is gone before another one tries to write anything

changeset d086d7325aa5 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=d086d7325aa5
summary: some silliness to make sure the writer goes away before the stream.  This should be fixed up proper some day

diffstat:

 apps/las2las.cpp                        |   6 ++++++
 apps/laskernel.cpp                      |  23 +++++++++++++----------
 include/liblas/detail/writer/writer.hpp |   2 +-
 src/detail/writer/writer.cpp            |  15 +++++++++++++--
 src/lasreader.cpp                       |   5 +----
 src/laswriter.cpp                       |   2 --
 6 files changed, 34 insertions(+), 19 deletions(-)

diffs (143 lines):

diff -r 7d1df24f6b90 -r d086d7325aa5 apps/las2las.cpp
--- a/apps/las2las.cpp	Wed Dec 15 09:32:11 2010 -0600
+++ b/apps/las2las.cpp	Wed Dec 15 10:54:05 2010 -0600
@@ -205,6 +205,12 @@
         RepairHeader(*summary, hnew);
         RewriteHeader(hnew, output);
     }
+
+    // cheap hackery.  We need the Writer to disappear before the stream.  
+    // Fix this up to not suck so bad.
+    writer = WriterPtr();   
+    ofs = OStreamPtr();
+    
     return true;
 }
 
diff -r 7d1df24f6b90 -r d086d7325aa5 apps/laskernel.cpp
--- a/apps/laskernel.cpp	Wed Dec 15 09:32:11 2010 -0600
+++ b/apps/laskernel.cpp	Wed Dec 15 10:54:05 2010 -0600
@@ -121,16 +121,19 @@
 
     std::ios::openmode m = std::ios::out | std::ios::in | std::ios::binary | std::ios::ate;
 
-    // Write a blank PointRecordsByReturnCount first
-    std::ofstream ofs(filename.c_str(), m);
-    liblas::Writer writer(ofs, header);
-    ofs.close();
-
-    // Write our updated header with summary info
-    std::ofstream ofs2(filename.c_str(), m);
-    liblas::Writer writer2(ofs2, header);
-    ofs2.close();
+    {
+        // Write a blank PointRecordsByReturnCount first
+        std::ofstream ofs(filename.c_str(), m);
+        liblas::Writer writer(ofs, header);
+        ofs.close();
+    }
     
+    {
+        // Write our updated header with summary info
+        std::ofstream ofs2(filename.c_str(), m);
+        liblas::Writer writer2(ofs2, header);
+        ofs2.close();
+    }
 }  
   
 void RepairHeader(liblas::Summary const& summary, liblas::Header& header)
@@ -290,7 +293,7 @@
         ("point-translate", po::value<std::string>(), "An expression to translate the X, Y, Z values of the point. For example, converting Z units that are in meters to feet: --point-translate \"x*1.0 y*1.0 z*3.2808399\"")
         ("color-source", po::value<std::string>(), "A string to a GDAL-openable raster data source.  Use GDAL VRTs if you want to adjust the data source or set its coordinate system, etc. \n--color-source \"afile.tif\" ")
         ("color-source-bands", po::value< std::vector<boost::uint32_t> >()->multitoken(), "A list of three bands from the --color-source to assign to the R, G, B  values for the point \n--color-source-bands 1 2 3")
-        ("color-source-scale", po::value< boost::uint32_t >(), "A number used by --color-source to scale the input R, G, B  values for the point.  For example, to scale the 8 bit color data from an input raster to 16 bit, the 8 bit data should be multiplied by 257. \n--color-source-scale 256")
+        ("color-source-scale", po::value< boost::uint32_t >(), "A number used by --color-source to scale the input R, G, B  values for the point.  For example, to scale the 8 bit color data from an input raster to 16 bit, the 8 bit data should be multiplied by 256. \n--color-source-scale 256")
 
     ;
     
diff -r 7d1df24f6b90 -r d086d7325aa5 include/liblas/detail/writer/writer.hpp
--- a/include/liblas/detail/writer/writer.hpp	Wed Dec 15 09:32:11 2010 -0600
+++ b/include/liblas/detail/writer/writer.hpp	Wed Dec 15 10:54:05 2010 -0600
@@ -74,7 +74,7 @@
     void SetTransforms(std::vector<liblas::TransformPtr> const& transforms);
 
 protected:
-    PointRecord m_record;
+
     std::ostream& m_ofs;
      
     PointWriterPtr m_point_writer;
diff -r 7d1df24f6b90 -r d086d7325aa5 src/detail/writer/writer.cpp
--- a/src/detail/writer/writer.cpp	Wed Dec 15 09:32:11 2010 -0600
+++ b/src/detail/writer/writer.cpp	Wed Dec 15 10:54:05 2010 -0600
@@ -77,6 +77,7 @@
     
     if ( count != 0 ) { out = count; }
     
+    if (!m_ofs.good() ) return;
     // Skip to first byte of number of point records data member
     std::streamsize const dataPos = 107; 
     m_ofs.seekp(dataPos, std::ios::beg);
@@ -85,7 +86,7 @@
 
 void WriterImpl::WritePoint(liblas::Point const& point)
 {
-    if (m_point_writer == 0) {
+    if (m_point_writer.get() == 0) {
         m_point_writer = PointWriterPtr(new writer::Point(m_ofs, m_pointCount, m_header));
     } 
     m_point_writer->write(point);
@@ -94,6 +95,16 @@
 
 WriterImpl::~WriterImpl()
 {
+    // Try to update the point count on our way out, but we don't really
+    // care if we weren't able to write it.
+    try
+    {
+        UpdatePointCount(0);
+        
+    } catch (std::runtime_error const&)
+    {
+        
+    }
 
 }
 
@@ -109,7 +120,7 @@
 
 liblas::Header& WriterImpl::GetHeader() const
 {
-    *m_header;
+    return *m_header;
 }
 void WriterImpl::SetHeader(liblas::Header const& header)
 {
diff -r 7d1df24f6b90 -r d086d7325aa5 src/lasreader.cpp
--- a/src/lasreader.cpp	Wed Dec 15 09:32:11 2010 -0600
+++ b/src/lasreader.cpp	Wed Dec 15 10:54:05 2010 -0600
@@ -97,10 +97,7 @@
 
 Reader::~Reader()
 {
-    // empty, but required so we can implement PIMPL using
-    // std::auto_ptr with incomplete type (Reader).
-    // delete m_empty_point;
-    
+
 }
 
 Header const& Reader::GetHeader() const
diff -r 7d1df24f6b90 -r d086d7325aa5 src/laswriter.cpp
--- a/src/laswriter.cpp	Wed Dec 15 09:32:11 2010 -0600
+++ b/src/laswriter.cpp	Wed Dec 15 10:54:05 2010 -0600
@@ -63,9 +63,7 @@
 
 Writer::~Writer()
 {
-    assert(0 != m_pimpl.get());
 
-    m_pimpl->UpdatePointCount(0);
 }
 
 Header const& Writer::GetHeader() const


More information about the Liblas-commits mailing list