[Liblas-commits] hg: as we read the points, we need to set their header to our he...

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Jun 21 15:02:48 EDT 2011


details:   http://hg.liblas.orghg/rev/d8595e79d3fd
changeset: 2971:d8595e79d3fd
user:      Howard Butler <hobu.inc at gmail.com>
date:      Tue Jun 21 14:02:17 2011 -0500
description:
as we read the points, we need to set their header to our header because the reader/writer they came from may go out of scope and invalidate our const&
Subject: hg: use eCompoundOK

details:   http://hg.liblas.orghg/rev/4b49b8d9631d
changeset: 2972:4b49b8d9631d
user:      Howard Butler <hobu.inc at gmail.com>
date:      Tue Jun 21 14:02:39 2011 -0500
description:
use eCompoundOK

diffstat:

 python/liblas/file.py               |  13 ++++++++++---
 test/unit/spatialreference_test.cpp |   4 ++--
 2 files changed, 12 insertions(+), 5 deletions(-)

diffs (67 lines):

diff -r f70806e4d64c -r 4b49b8d9631d python/liblas/file.py
--- a/python/liblas/file.py	Tue Jun 21 13:47:03 2011 -0500
+++ b/python/liblas/file.py	Tue Jun 21 14:02:39 2011 -0500
@@ -164,6 +164,7 @@
             self.handle = core.las.LASWriter_Create(self.filename,
                                                     self._header,
                                                     1)
+            self._header = core.las.LASWriter_GetHeader(self.handle)
             self.mode = 1
             files['write'].append(self.filename)
 
@@ -181,6 +182,8 @@
             self.handle = core.las.LASWriter_Create(self.filename,
                                                     self._header,
                                                     2)
+            core.las.LASHeader_Destroy(self._header)
+            self._header = core.las.LASWriter_GetHeader(self.handle)
             self.mode = 2
             files['append'].append(self.filename)
 
@@ -296,10 +299,12 @@
     def read(self, index):
         """Reads the point at the given index"""
         if self.mode == 0:
-            return point.Point(
+            p = point.Point(
             handle=core.las.LASReader_GetPointAt(self.handle, index),
             copy=True)
-
+            p.set_header(lasheader.Header(handle=self._header, copy=False))
+            return p
+            
     def seek(self, index):
         """Seeks to the point at the given index.  Subsequent calls \
 	   to :meth:`next` will then start at that point."""
@@ -319,7 +324,9 @@
             self.at_end = False
             p = core.las.LASReader_GetNextPoint(self.handle)
             while p and not self.at_end:
-                yield point.Point(handle=p, copy=True)
+                p2 = point.Point(handle=p, copy=True)
+                p2.set_header(lasheader.Header(handle=self._header, copy=False))
+                yield p2
                 p = core.las.LASReader_GetNextPoint(self.handle)
                 if not p:
                     self.at_end = True
diff -r f70806e4d64c -r 4b49b8d9631d test/unit/spatialreference_test.cpp
--- a/test/unit/spatialreference_test.cpp	Tue Jun 21 13:47:03 2011 -0500
+++ b/test/unit/spatialreference_test.cpp	Tue Jun 21 14:02:39 2011 -0500
@@ -215,7 +215,7 @@
         ref.SetFromUserInput(wkt_c);
         
         liblas::SpatialReference test_ref;
-        test_ref.SetWKT(ref.GetWKT());
+        test_ref.SetWKT(ref.GetWKT(liblas::SpatialReference::eCompoundOK));
         ensure_equals("WKT comparison", ref, test_ref );
         
         std::vector<liblas::VariableRecord> const& vlrs = ref.GetVLRs();
@@ -238,7 +238,7 @@
         ref2.SetWKT(wkt_c);
         
         liblas::SpatialReference test_ref2;
-        test_ref2.SetWKT(ref2.GetWKT());
+        test_ref2.SetWKT(ref2.GetWKT(liblas::SpatialReference::eCompoundOK));
         ensure_equals("WKT comparison from geotiff", ref2, test_ref2 );
 
     }


More information about the Liblas-commits mailing list