[Liblas-commits] hg: 3 new changesets

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Nov 4 12:56:24 EDT 2010


changeset db9669608b28 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=db9669608b28
summary: clean off extra comma

changeset b26c785ad8eb in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=b26c785ad8eb
summary: updates for changes

changeset 04d40d3a1304 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=04d40d3a1304
summary: attempt to move on in the case of a bad point count in the header

diffstat:

 python/tests/Header.txt      |   2 +-
 python/tests/SRS-GDAL.txt    |   3 +-
 src/detail/reader/header.cpp |  54 ++++++++++++++++++++++++++++++-------------
 src/utility.cpp              |   4 +-
 4 files changed, 42 insertions(+), 21 deletions(-)

diffs (111 lines):

diff -r 6f6ba5423748 -r 04d40d3a1304 python/tests/Header.txt
--- a/python/tests/Header.txt	Thu Nov 04 10:59:24 2010 -0500
+++ b/python/tests/Header.txt	Thu Nov 04 11:56:14 2010 -0500
@@ -48,7 +48,7 @@
   datetime.datetime(2008, 3, 19, 0, 0)
 
   >>> h.software_id
-  'libLAS 1.2'
+  'libLAS 1.6.0b2'
   >>> h.software_id = 'hobu'
   >>> h.software_id
   'hobu'
diff -r 6f6ba5423748 -r 04d40d3a1304 python/tests/SRS-GDAL.txt
--- a/python/tests/SRS-GDAL.txt	Thu Nov 04 10:59:24 2010 -0500
+++ b/python/tests/SRS-GDAL.txt	Thu Nov 04 11:56:14 2010 -0500
@@ -107,7 +107,8 @@
   >>> del f_project
   >>> f3 = file.File('junk_srs_project.las')
   >>> f3.header.data_offset
-  476L
+  477L
+
   >>> s_utm = srs.SRS()
   >>> s_utm.wkt = utm_wkt
   >>> p3 = f3.read(1)
diff -r 6f6ba5423748 -r 04d40d3a1304 src/detail/reader/header.cpp
--- a/src/detail/reader/header.cpp	Thu Nov 04 10:59:24 2010 -0500
+++ b/src/detail/reader/header.cpp	Thu Nov 04 11:56:14 2010 -0500
@@ -294,24 +294,44 @@
         m_ifs.seekg(0, std::ios::end);
         std::ios::pos_type end = m_ifs.tellg();
         std::ios::off_type size = end - beginning;
-     
-        // Figure out how many points we have 
-        std::ios::off_type count = (end - static_cast<std::ios::off_type>(m_header->GetDataOffset())) / 
-                                     static_cast<std::ios::off_type>(m_header->GetDataRecordLength());
-    
+        std::ios::off_type offset = static_cast<std::ios::off_type>(m_header->GetDataOffset());
+        std::ios::off_type length = static_cast<std::ios::off_type>(m_header->GetDataRecordLength());
+        std::ios::off_type point_bytes = end - offset;
+
+        // Figure out how many points we have and whether or not we have 
+        // extra slop in there.
+        std::ios::off_type count = point_bytes / length;
+        std::ios::off_type remainder = point_bytes % length;
+        
+
         if ( m_header->GetPointRecordsCount() != static_cast<uint32_t>(count)) {
-            std::ostringstream msg; 
-            msg <<  "The number of points in the header that was set "
-                    "by the software '" << m_header->GetSoftwareId() <<
-                    "' does not match the actual number of points in the file "
-                    "as determined by subtracting the data offset (" 
-                    <<m_header->GetDataOffset() << ") from the file length (" 
-                    << size <<  ") and dividing by the point record length(" 
-                    << m_header->GetDataRecordLength() << "). "
-                    " Actual number of points: " << count << 
-                    " Header-specified number of points: " 
-                    << m_header->GetPointRecordsCount() ;
-            throw std::runtime_error(msg.str());
+            if (remainder == 0)
+            {
+                // The point bytes are exactly long enough, let's use it
+                // Set the count to what we calculated
+                m_header->SetPointRecordsCount(static_cast<boost::uint32_t>(count));
+                
+            } 
+            else 
+            {
+                std::ostringstream msg; 
+                msg <<  "The number of points in the header that was set "
+                        "by the software '" << m_header->GetSoftwareId() <<
+                        "' does not match the actual number of points in the file "
+                        "as determined by subtracting the data offset (" 
+                        <<m_header->GetDataOffset() << ") from the file length (" 
+                        << size <<  ") and dividing by the point record length (" 
+                        << m_header->GetDataRecordLength() << ")."
+                        " It also does not perfectly contain an exact number of"
+                        " point data and we cannot infer a point count."
+                        " Calculated number of points: " << count << 
+                        " Header-specified number of points: " 
+                        << m_header->GetPointRecordsCount() <<
+                        " Point data remainder: " << remainder;
+                throw std::runtime_error(msg.str());                
+            }
+
+
         
         }
     }
diff -r 6f6ba5423748 -r 04d40d3a1304 src/utility.cpp
--- a/src/utility.cpp	Thu Nov 04 10:59:24 2010 -0500
+++ b/src/utility.cpp	Thu Nov 04 11:56:14 2010 -0500
@@ -327,7 +327,7 @@
     os.precision(y_precision);
     os << tree.get<double>("summary.points.minimum.y") << ", ";
     os.precision(z_precision);
-    os << tree.get<double>("summary.points.minimum.z") << ", ";
+    os << tree.get<double>("summary.points.minimum.z");
 
     os << std::endl;
     os << "  Max X, Y, Z: \t\t";
@@ -337,7 +337,7 @@
     os.precision(y_precision);
     os << tree.get<double>("summary.points.maximum.y") << ", ";
     os.precision(z_precision);
-    os << tree.get<double>("summary.points.maximum.z") << ", ";
+    os << tree.get<double>("summary.points.maximum.z");
     
     os << std::endl;
     os << "  Bounding Box:\t\t";


More information about the Liblas-commits mailing list