[Liblas-commits] hg: 4 new changesets

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Sep 8 15:52:04 EDT 2010


changeset 5517deb95207 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=5517deb95207
summary: fix up write support to not touch VLRs if we are in append mode at all -- add in the schema and georeference VLRs if we are in write mode

changeset b25ebaa3e62e in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=b25ebaa3e62e
summary: more operator<< output

changeset 73c4cf525f6a in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=73c4cf525f6a
summary: refactor a DeleteVLR(name, id) method and remove the one-use ClearGeoKeyVLRs so we can remove any types of VLRs we want

changeset acd7cbc2f615 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=acd7cbc2f615
summary: rework schema stuff so tests pass.  Schema stuff isn't really tested yet, as it's not done

diffstat:

 include/liblas/lasheader.hpp |    5 +-
 python/liblas/core.py        |   90 ++++++------------
 python/liblas/header.py      |   12 +-
 python/liblas/schema.py      |   45 +--------
 python/tests/File.txt        |  123 +++++++++++++------------
 python/tests/Header.txt      |    9 -
 python/tests/Schema.txt      |   29 +-----
 python/tests/VLR.txt         |    2 +
 src/detail/writer/header.cpp |  100 +++++++++++++-------
 src/las_c_api.cpp            |  204 +++++++++---------------------------------
 src/lasheader.cpp            |   42 ++------
 src/lasschema.cpp            |   20 +++-
 12 files changed, 252 insertions(+), 429 deletions(-)

diffs (truncated from 970 to 300 lines):

diff -r 31e2ea4c3b90 -r acd7cbc2f615 include/liblas/lasheader.hpp
--- a/include/liblas/lasheader.hpp	Wed Sep 08 08:57:06 2010 -0500
+++ b/include/liblas/lasheader.hpp	Wed Sep 08 14:51:48 2010 -0500
@@ -316,6 +316,7 @@
 
     /// Removes a VLR from the the header.
     void DeleteVLR(boost::uint32_t index);
+    void DeleteVLR(std::string const& name, boost::uint16_t id);
 
     /// Rewrite variable-length record with georeference infomation, if available.
     void SetGeoreference();
@@ -346,7 +347,7 @@
     /// Returns a property_tree that contains 
     /// all of the header data in a structured format.
     liblas::property_tree::ptree GetPTree() const;
-
+    
 private:
     
     typedef detail::Point<double> PointScales;
@@ -371,8 +372,6 @@
     // Private function members
     //
     void Init();
-    void ClearGeoKeyVLRs();
-    // void UpdateSchema();
 
     //
     // Private data members
diff -r 31e2ea4c3b90 -r acd7cbc2f615 python/liblas/core.py
--- a/python/liblas/core.py	Wed Sep 08 08:57:06 2010 -0500
+++ b/python/liblas/core.py	Wed Sep 08 14:51:48 2010 -0500
@@ -729,64 +729,38 @@
 las.LASHeader_SetSRS.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
 las.LASHeader_SetSRS.errcheck = check_return
 
-# las.LASHeader_GetSchema.argtypes = [ctypes.c_void_p]
-# las.LASHeader_GetSchema.errcheck = check_void
-# las.LASHeader_GetSchema.restype = ctypes.c_void_p
-# 
-# las.LASHeader_SetSchema.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
-# las.LASHeader_SetSchema.errcheck = check_return
-# las.LASHeader_SetSchema.restype = ctypes.c_int
-# 
-# las.LASSchema_Create.argtypes = [ctypes.c_uint8,
-#                                         ctypes.c_uint8,
-#                                         ctypes.c_uint32,
-#                                         ctypes.c_uint8,
-#                                         ctypes.c_uint8]
-# las.LASSchema_Create.errcheck = check_void
-# las.LASSchema_Create.restype = ctypes.c_void_p
-# 
-# las.LASSchema_GetByteSize.restype = ctypes.c_ushort
-# las.LASSchema_GetByteSize.argtypes = [ctypes.c_void_p]
-# las.LASSchema_GetByteSize.errcheck = check_value
-# las.LASSchema_SetByteSize.restype = ctypes.c_int
-# las.LASSchema_SetByteSize.argtypes = [ctypes.c_void_p, ctypes.c_ushort]
-# las.LASSchema_SetByteSize.errcheck = check_return
-# 
-# las.LASSchema_GetBaseByteSize.restype = ctypes.c_ushort
-# las.LASSchema_GetBaseByteSize.argtypes = [ctypes.c_void_p]
-# las.LASSchema_GetBaseByteSize.errcheck = check_value
-# 
-# las.LASSchema_HasColor.restype = ctypes.c_uint8
-# las.LASSchema_HasColor.argtypes = [ctypes.c_void_p]
-# las.LASSchema_HasColor.errcheck = check_value
-# las.LASSchema_SetColor.restype = ctypes.c_int
-# las.LASSchema_SetColor.argtypes = [ctypes.c_void_p, ctypes.c_uint8]
-# las.LASSchema_SetColor.errcheck = check_return
-# 
-# las.LASSchema_HasTime.restype = ctypes.c_uint8
-# las.LASSchema_HasTime.argtypes = [ctypes.c_void_p]
-# las.LASSchema_HasTime.errcheck = check_value
-# las.LASSchema_SetTime.restype = ctypes.c_int
-# las.LASSchema_SetTime.argtypes = [ctypes.c_void_p, ctypes.c_uint8]
-# las.LASSchema_SetTime.errcheck = check_return
-# 
-# las.LASSchema_GetVersionMinor.restype = ctypes.c_uint8
-# las.LASSchema_GetVersionMinor.argtypes = [ctypes.c_void_p]
-# las.LASSchema_GetVersionMinor.errcheck = check_value
-# las.LASSchema_SetVersionMinor.restype = ctypes.c_int
-# las.LASSchema_SetVersionMinor.argtypes = [ctypes.c_void_p, ctypes.c_uint8]
-# las.LASSchema_SetVersionMinor.errcheck = check_return
-# 
-# las.LASSchema_GetVersionMajor.restype = ctypes.c_uint8
-# las.LASSchema_GetVersionMajor.argtypes = [ctypes.c_void_p]
-# las.LASSchema_GetVersionMajor.errcheck = check_value
-# las.LASSchema_SetVersionMajor.restype = ctypes.c_int
-# las.LASSchema_SetVersionMajor.argtypes = [ctypes.c_void_p, ctypes.c_uint8]
-# las.LASSchema_SetVersionMajor.errcheck = check_return
-# 
-# las.LASSchema_Destroy.argtypes = [ctypes.c_void_p]
-# las.LASSchema_Destroy.errcheck = check_void_done
-# las.LASSchema_Destroy.restype = None
+las.LASHeader_GetSchema.argtypes = [ctypes.c_void_p]
+las.LASHeader_GetSchema.errcheck = check_void
+las.LASHeader_GetSchema.restype = ctypes.c_void_p
+
+las.LASHeader_SetSchema.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
+las.LASHeader_SetSchema.errcheck = check_return
+las.LASHeader_SetSchema.restype = ctypes.c_int
+
+las.LASSchema_Create.argtypes = [ctypes.c_uint32]
+                                        
+las.LASSchema_Create.errcheck = check_void
+las.LASSchema_Create.restype = ctypes.c_void_p
+
+las.LASSchema_GetByteSize.restype = ctypes.c_ushort
+las.LASSchema_GetByteSize.argtypes = [ctypes.c_void_p]
+las.LASSchema_GetByteSize.errcheck = check_value
+
+
+
+las.LASSchema_HasColor.restype = ctypes.c_uint8
+las.LASSchema_HasColor.argtypes = [ctypes.c_void_p]
+las.LASSchema_HasColor.errcheck = check_value
+
+
+las.LASSchema_HasTime.restype = ctypes.c_uint8
+las.LASSchema_HasTime.argtypes = [ctypes.c_void_p]
+las.LASSchema_HasTime.errcheck = check_value
+
+
+las.LASSchema_Destroy.argtypes = [ctypes.c_void_p]
+las.LASSchema_Destroy.errcheck = check_void_done
+las.LASSchema_Destroy.restype = None
 
 las.LASString_Free.argtypes = [ctypes.POINTER(ctypes.c_char_p)]
 las.LASString_Free.restype = None
diff -r 31e2ea4c3b90 -r acd7cbc2f615 python/liblas/header.py
--- a/python/liblas/header.py	Wed Sep 08 08:57:06 2010 -0500
+++ b/python/liblas/header.py	Wed Sep 08 14:51:48 2010 -0500
@@ -196,14 +196,12 @@
     def get_majorversion(self):
         """Returns the major version for the file. Expect this value to always
         be 1"""
-        return self.schema.major
+        return core.las.LASHeader_GetVersionMajor(self.handle)
 
     def set_majorversion(self, value):
         """Sets the major version for the file. Only the value 1 is accepted
         at this time"""
-        f = self.schema
-        f.major = value
-        self.schema = f
+        return core.las.LASHeader_SetVersionMajor(self.handle, value)
     doc = """Major version number for the file.  For all practical purposes, \
     this is always '1'"""
     major_version = property(get_majorversion, set_majorversion, None, doc)
@@ -213,14 +211,12 @@
     def get_minorversion(self):
         """Returns the minor version of the file. Expect this value to always
         be 0, 1, or 2"""
-        return self.schema.minor
+        return core.las.LASHeader_GetVersionMinor(self.handle)
 
     def set_minorversion(self, value):
         """Sets the minor version of the file. The value should be 0 for 1.0
         LAS files, 1 for 1.1 LAS files ..."""
-        f = self.schema
-        f.minor = value
-        self.schema = f
+        return core.las.LASHeader_SetVersionMinor(self.handle, value)
     doc = """Minor version for the file. [0, 1, 2] are currently supported."""
     minor_version = property(get_minorversion, set_minorversion, None, doc)
     version_minor = minor_version
diff -r 31e2ea4c3b90 -r acd7cbc2f615 python/liblas/schema.py
--- a/python/liblas/schema.py	Wed Sep 08 08:57:06 2010 -0500
+++ b/python/liblas/schema.py	Wed Sep 08 14:51:48 2010 -0500
@@ -45,15 +45,11 @@
 
 
 class Schema(object):
-    """:class:`liblas.format.Format` is an object that keeps track of the
+    """:class:`liblas.schema.Schema` is an object that keeps track of the
     point format sizes and what data elements the point formats have (color,
     time, etc), as well as accounting for their size in bytes. """
 
-    def __init__(self,  major=1,
-                        minor=2,
-                        time=False,
-                        color=False,
-                        size=0,
+    def __init__(self,  point_format=0,
                         handle=None):
         """
         :keyword major: Major version value (always 1 for libLAS)
@@ -88,33 +84,13 @@
         if handle:
             self.handle = handle
         else:
-            self.handle = core.las.LASSchema_Create(major,
-                                                         minor,
-                                                         size,
-                                                         time,
-                                                         color)
+            self.handle = core.las.LASSchema_Create(point_format)
 
     def __del__(self):
         if self.handle and core:
             core.las.LASSchema_Destroy(self.handle)
 
-    def get_major(self):
-        return core.las.LASSchema_GetVersionMajor(self.handle)
 
-    def set_major(self, value):
-        return core.las.LASSchema_SetVersionMajor(self.handle, int(value))
-
-    doc = """Major version for the format.  Always 1 for libLAS."""
-    major = property(get_major, set_major, None, doc)
-
-    def get_minor(self):
-        return core.las.LASSchema_GetVersionMinor(self.handle)
-
-    def set_minor(self, value):
-        return core.las.LASSchema_SetVersionMinor(self.handle, int(value))
-
-    doc = """Minor version for the format. Can be 0, 1, 2, 3. No validation"""
-    minor = property(get_minor, set_minor, None, doc)
 
     def get_size(self):
         return core.las.LASSchema_GetByteSize(self.handle)
@@ -125,26 +101,15 @@
     doc = """Size in bytes of the format.  """
     size = property(get_size, set_size, None, doc)
 
-    def get_base_size(self):
-        return core.las.LASSchema_GetBaseByteSize(self.handle)
-
-    doc = """Base size in bytes of the format. (only accounting for time,
-    color, etc.)"""
-    base_size = property(get_base_size, None, None, doc)
 
     def get_color(self):
         return bool(core.las.LASSchema_HasColor(self.handle))
 
-    def set_color(self, value):
-        return core.las.LASSchema_SetColor(self.handle, bool(value))
-
     doc = """Does this format have color information"""
-    color = property(get_color, set_color, None, doc)
+    color = property(get_color, None, None, doc)
 
     def get_time(self):
         return bool(core.las.LASSchema_HasTime(self.handle))
 
-    def set_time(self, value):
-        return core.las.LASSchema_SetTime(self.handle, bool(value))
     doc = """Does this format have time information"""
-    time = property(get_time, set_time, None, doc)
+    time = property(get_time, None, None, doc)
diff -r 31e2ea4c3b90 -r acd7cbc2f615 python/tests/File.txt
--- a/python/tests/File.txt	Wed Sep 08 08:57:06 2010 -0500
+++ b/python/tests/File.txt	Wed Sep 08 14:51:48 2010 -0500
@@ -141,6 +141,14 @@
   >>> f.header
 
   >>> del f
+  
+Go read the new header we've written.  It might be out of date because what 
+was written in mode='w' might not equal what was passed in as the header= paramete
+
+  >>> f2 = file.File('junk.las')
+  >>> h = f2.header
+  >>> f2.close()
+  
   >>> f = file.File('junk.las', mode='w+', header=h)
   
   >>> for i in points:
@@ -297,69 +305,70 @@
   630280.89
 
 
-The following tests writing out point data that are larger in size than 
-the base point format, allowing you to store extra data.  
-
-  >>> f6 = file.File('../test/data/TO_core_last_clip.las')
-  >>> p2 = f6.read(6)
-  >>> p2.x, p2.y, p2.z
-  (630320.95999999996, 4834500.0, 55.009999999999998)
-
-  >>> h6 = f6.header
-  >>> f = h6.schema
-  >>> f.time = True
-  >>> f.color = True
-  >>> f.size = 52
-  >>> h6.schema = f
-  >>> h6.data_record_length
-  52
-
-  
-f.size - f.base_size will be 16 bytes of space (h6.data_record_length - 34 bytes for point format 3)
-
->>> import ctypes
- 
-  >>> d = (ctypes.c_ubyte * (f.size - f.base_size))() 
-  >>> d[10]
-  0
-  >>> d[0] = 13
-


More information about the Liblas-commits mailing list