[Liblas-commits] hg: implement GetRaw{X|Y|Z} for Python #228

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Jun 22 11:32:50 EDT 2011


details:   http://hg.liblas.orghg/rev/452c693ee4dc
changeset: 2980:452c693ee4dc
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed Jun 22 10:32:44 2011 -0500
description:
implement GetRaw{X|Y|Z} for Python #228

diffstat:

 python/liblas/core.py  |   24 ++++++++++
 python/liblas/point.py |  109 ++++++++++++++++++++++++++++++++++++++++--------
 python/tests/Point.txt |   52 +++++++++++++---------
 3 files changed, 145 insertions(+), 40 deletions(-)

diffs (273 lines):

diff -r 85d88e7ce5ea -r 452c693ee4dc python/liblas/core.py
--- a/python/liblas/core.py	Wed Jun 22 09:39:09 2011 -0500
+++ b/python/liblas/core.py	Wed Jun 22 10:32:44 2011 -0500
@@ -219,6 +219,14 @@
 las.LASPoint_SetX.argtypes = [ctypes.c_void_p, ctypes.c_double]
 las.LASPoint_SetX.errcheck = check_return
 
+las.LASPoint_GetRawX.restype = ctypes.c_long
+las.LASPoint_GetRawX.argtypes = [ctypes.c_void_p]
+las.LASPoint_GetRawX.errcheck = check_value
+las.LASPoint_SetRawX.restype = ctypes.c_int
+las.LASPoint_SetRawX.argtypes = [ctypes.c_void_p, ctypes.c_long]
+las.LASPoint_SetRawX.errcheck = check_return
+
+
 las.LASPoint_GetY.restype = ctypes.c_double
 las.LASPoint_GetY.argtypes = [ctypes.c_void_p]
 las.LASPoint_GetY.errcheck = check_value
@@ -226,6 +234,14 @@
 las.LASPoint_SetY.argtypes = [ctypes.c_void_p, ctypes.c_double]
 las.LASPoint_SetY.errcheck = check_return
 
+las.LASPoint_GetRawY.restype = ctypes.c_long
+las.LASPoint_GetRawY.argtypes = [ctypes.c_void_p]
+las.LASPoint_GetRawY.errcheck = check_value
+las.LASPoint_SetRawY.restype = ctypes.c_int
+las.LASPoint_SetRawY.argtypes = [ctypes.c_void_p, ctypes.c_long]
+las.LASPoint_SetRawY.errcheck = check_return
+
+
 las.LASPoint_GetZ.restype = ctypes.c_double
 las.LASPoint_GetZ.argtypes = [ctypes.c_void_p]
 las.LASPoint_GetZ.errcheck = check_value
@@ -233,6 +249,14 @@
 las.LASPoint_SetZ.argtypes = [ctypes.c_void_p, ctypes.c_double]
 las.LASPoint_SetZ.errcheck = check_return
 
+las.LASPoint_GetRawZ.restype = ctypes.c_long
+las.LASPoint_GetRawZ.argtypes = [ctypes.c_void_p]
+las.LASPoint_GetRawZ.errcheck = check_value
+las.LASPoint_SetRawZ.restype = ctypes.c_int
+las.LASPoint_SetRawZ.argtypes = [ctypes.c_void_p, ctypes.c_long]
+las.LASPoint_SetRawZ.errcheck = check_return
+
+
 las.LASPoint_GetIntensity.restype = ctypes.c_short
 las.LASPoint_GetIntensity.argtypes = [ctypes.c_void_p]
 las.LASPoint_GetIntensity.errcheck = check_value
diff -r 85d88e7ce5ea -r 452c693ee4dc python/liblas/point.py
--- a/python/liblas/point.py	Wed Jun 22 09:39:09 2011 -0500
+++ b/python/liblas/point.py	Wed Jun 22 10:32:44 2011 -0500
@@ -93,18 +93,43 @@
         return core.las.LASPoint_GetX(self.handle)
 
     def set_x(self, value):
-        """Sets the X coordinate of the LAS point to a floating point value."""
+        """Sets the X coordinate of the LAS point to a floating point
+        value. 
+        
+        ..note:: 
+            The point will be descaled according to the :obj:`liblas.point.Point.header`'s  
+            scale value for the X dimension.
+        """
+
         return core.las.LASPoint_SetX(self.handle, value)
 
-    doc = """X coordinate of the LAS point.
+    doc = """X coordinate of the LAS point as a double (scale applied).
 
     .. note::
-        You are expected to properly de-scale the point according to the
-        offset and the X scale if it is a free-standing point. When points are
-        written to a LAS file, they will be scaled according to the header
-        parameters
+        Use obj:`liblas.point.Point.raw_x` if you want the unscaled ``x`` data.
     """
 
+    def get_raw_x(self):
+        return core.las.LASPoint_GetRawX(self.handle)
+
+    def set_raw_x(self, value):
+        """Sets the X coordinate of the LAS point to an integer value
+        value. 
+        
+        ..note:: 
+            The point will be scaled according to the obj:`liblas.point.Point.header`'s 
+            scale value for the X dimension when returned as a double obj:`liblas.point.Point.x`.
+        """
+        return core.las.LASPoint_SetRawX(self.handle, value)
+
+    doc = """The raw X coordinate of the point without its header's scaling
+            applied.
+
+    .. note::
+        Use obj:`liblas.point.Point.x` if you want the scaled ``x`` data.
+    """
+    raw_x = property(get_raw_x, set_raw_x, None, doc)
+
     x = property(get_x, set_x, None, doc)
 
     def get_y(self):
@@ -112,36 +137,84 @@
 
     def set_y(self, value):
         """Sets the Y coordinate of the LAS point to a floating point
-        value."""
+        value. 
+        
+        ..note:: 
+            The point will be descaled according to the :obj:`liblas.point.Point.header`'s 
+            scale value for the Y dimension.
+        """
         return core.las.LASPoint_SetY(self.handle, value)
 
-    doc = """Y coordinate of the LAS point.
+    doc = """Y coordinate of the LAS point as a double (scale applied).
 
     .. note::
-        You are expected to properly de-scale the point according to the
-        offset and the X scale if it is a free-standing point. When points are
-        written to a LAS file, they will be scaled according to the header
-        parameters
+        Use obj:`liblas.point.Point.raw_y` if you want the unscaled ``y`` data.
     """
+
     y = property(get_y, set_y, None, doc)
 
+    def get_raw_y(self):
+        return core.las.LASPoint_GetRawY(self.handle)
+
+    def set_raw_y(self, value):
+        """Sets the Y coordinate of the LAS point to an integer value
+        value. 
+        
+        ..note:: 
+            The point will be scaled according to the obj:`liblas.point.Point.header`'s 
+            scale value for the Y dimension when returned as a double obj:`liblas.point.Point.y`.
+        """
+        return core.las.LASPoint_SetRawY(self.handle, value)
+
+    doc = """The raw Y coordinate of the point without its header's scaling
+            applied.
+
+    .. note::
+        Use obj:`liblas.point.Point.y` if you want the scaled ``y`` data.
+    """
+    raw_y = property(get_raw_y, set_raw_y, None, doc)
+
     def get_z(self):
         return core.las.LASPoint_GetZ(self.handle)
 
     def set_z(self, value):
-        """Sets the Z coordinate of the LAS point to a floating point value."""
+        """Sets the Z coordinate of the LAS point to a floating point
+        value. 
+        
+        ..note:: 
+            The point will be descaled according to the obj:`liblas.point.Point.header`'s 
+            scale value for the Z dimension.
+        """
         return core.las.LASPoint_SetZ(self.handle, value)
 
-    doc = """Z coordinate of the LAS point.
+    doc = """Z coordinate of the LAS point as a double (scale applied).
 
     .. note::
-        You are expected to properly de-scale the point according to the
-        offset and the X scale if it is a free-standing point. When points are
-        written to a LAS file, they will be scaled according to the header
-        parameters
+        Use obj:`liblas.point.Point.raw_z` if you want the unscaled ``z`` data.
     """
     z = property(get_z, set_z, None, doc)
 
+    def get_raw_z(self):
+        return core.las.LASPoint_GetRawZ(self.handle)
+
+    def set_raw_z(self, value):
+        """Sets the Z coordinate of the LAS point to an integer value
+        value. 
+        
+        ..note:: 
+            The point will be scaled according to the obj:`liblas.point.Point.header`'s 
+            scale value for the Z dimension when returned as a double obj:`liblas.point.Point.y`.
+        """
+        return core.las.LASPoint_SetRawZ(self.handle, value)
+
+    doc = """The raw Z coordinate of the point without its header's scaling
+            applied.
+
+    .. note::
+        Use obj:`liblas.point.Point.z` if you want the scaled ``z`` data.
+    """
+    raw_z = property(get_raw_z, set_raw_z, None, doc)
+    
     def get_return_number(self):
         """Returns the return number of the point"""
         return core.las.LASPoint_GetReturnNumber(self.handle)
diff -r 85d88e7ce5ea -r 452c693ee4dc python/tests/Point.txt
--- a/python/tests/Point.txt	Wed Jun 22 09:39:09 2011 -0500
+++ b/python/tests/Point.txt	Wed Jun 22 10:32:44 2011 -0500
@@ -7,18 +7,24 @@
   >>> p.x = 1.0
   >>> p.x
   1.0
+  >>> p.raw_x
+  100
 
   >>> p.y
   0.0
-  >>> p.y = 1.0
+  >>> p.y = 2.0
   >>> p.y
-  1.0
+  2.0
+  >>> p.raw_y
+  200
 
   >>> p.z
   0.0
-  >>> p.z = 1.0
+  >>> p.z = 3.0
   >>> p.z
-  1.0
+  3.0
+  >>> p.raw_z
+  300
 
   >>> p.return_number
   0
@@ -94,22 +100,24 @@
   >>> p.color = c
   >>> p.color.red
   124
-  
-  >>> import ctypes
-  >>> data = (ctypes.c_ubyte * 256)()
-  >>> data[10]
-  0
-  
-  >>> for i in range(256):
-  ...     data[i] = 2+i
-  
-  >>> data[10]
-  12
-  >>> p.data = data
-  
-# Ensure we can round trip the data
-  >>> [data[i] for i in range(10)]
-  [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
-  >>> [p.data[i] for i in range(10)]
-  [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
 
+
+#   
+#   >>> import ctypes
+#   >>> data = (ctypes.c_ubyte * 256)()
+#   >>> data[10]
+#   0
+#   
+#   >>> for i in range(256):
+#   ...     data[i] = 2+i
+#   
+#   >>> data[10]
+#   12
+#   >>> p.data = data
+#   
+# # Ensure we can round trip the data
+#   >>> [data[i] for i in range(10)]
+#   [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
+#   >>> [p.data[i] for i in range(10)]
+#   [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
+


More information about the Liblas-commits mailing list