[Liblas-commits] hg: 2 new changesets

liblas-commits at liblas.org liblas-commits at liblas.org
Fri Jun 18 11:07:13 EDT 2010


changeset 6e77d643eb1f in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=6e77d643eb1f
summary: typo

changeset 9a061e681940 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=9a061e681940
summary: partial fix for #147, seeking off the end of the file

diffstat:

 doc/compilation.txt          |   2 +-
 src/detail/writer/header.cpp |  17 ++++++++++-------
 2 files changed, 11 insertions(+), 8 deletions(-)

diffs (51 lines):

diff -r 14da39665f17 -r 9a061e681940 doc/compilation.txt
--- a/doc/compilation.txt	Thu Jun 17 20:57:42 2010 -0500
+++ b/doc/compilation.txt	Fri Jun 18 10:07:04 2010 -0500
@@ -569,7 +569,7 @@
 
 .. note::
     If you are building using `OSGeo4W`_ libraries, you must use the "gdal-dev" 
-    version, not the base `GDAL`_ build.  libLAS requires GDDAL 1.7+ to 
+    version, not the base `GDAL`_ build.  libLAS requires GDAL 1.7+ to 
     operate, and this is provided by the "gdal-dev" `OSGeo4W`_ version.
 
 .. note::
diff -r 14da39665f17 -r 9a061e681940 src/detail/writer/header.cpp
--- a/src/detail/writer/header.cpp	Thu Jun 17 20:57:42 2010 -0500
+++ b/src/detail/writer/header.cpp	Fri Jun 18 10:07:04 2010 -0500
@@ -74,6 +74,8 @@
     // Rewrite the georeference VLR entries if they exist
     m_header.SetGeoreference();
     
+    // Figure out how many points we already have.  
+
     // Seek to the beginning
     GetStream().seekp(0, std::ios::beg);
     std::ios::pos_type beginning = GetStream().tellp();
@@ -81,18 +83,19 @@
     // Seek to the end
     GetStream().seekp(0, std::ios::end);
     std::ios::pos_type end = GetStream().tellp();
-    
-    // Figure out how many points we already have.  Each point record 
-    // should be 20 bytes long, and header.GetDataOffset tells
-    // us the location to start counting points from.  
+    // std::ios::off_type size = end - beginning;
+     
+    std::ios::off_type count = (end - static_cast<std::ios::off_type>(m_header.GetDataOffset())) / 
+                                 static_cast<std::ios::off_type>(m_header.GetDataRecordLength());
     
     // This test should only be true if we were opened in both 
     // std::ios::in *and* std::ios::out, otherwise it should return false 
     // and we won't adjust the point count.
     
-    if ((beginning != end) && ((uint32_t)end != 0)) {
-        uint32_t count = ((uint32_t) end - m_header.GetDataOffset())/m_header.GetDataRecordLength();
-        SetPointCount(count);
+    if ((beginning != end) && (end != 0)) {
+        liblas::uint32_t& cnt =  GetPointCount();
+        cnt = static_cast<liblas::uint32_t>(count);
+        SetPointCount(cnt);
 
         // Position to the beginning of the file to start writing the header
         GetStream().seekp(0, std::ios::beg);


More information about the Liblas-commits mailing list