[Liblas-commits] hg: return raw values to ptree

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Jun 22 11:47:07 EDT 2011


details:   http://hg.liblas.orghg/rev/73e5700ae093
changeset: 2981:73e5700ae093
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed Jun 22 10:45:16 2011 -0500
description:
return raw values to ptree
Subject: hg: add GetXML method for liblas::Point #229

details:   http://hg.liblas.orghg/rev/6a035fab789a
changeset: 2982:6a035fab789a
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed Jun 22 10:47:01 2011 -0500
description:
add GetXML method for liblas::Point #229

diffstat:

 include/liblas/capi/liblas.h |   6 ++++++
 python/liblas/core.py        |   5 ++++-
 python/liblas/point.py       |   7 +++++++
 python/tests/Point.txt       |   5 +++++
 src/c_api.cpp                |  14 ++++++++++++++
 src/point.cpp                |   4 ++++
 6 files changed, 40 insertions(+), 1 deletions(-)

diffs (115 lines):

diff -r 452c693ee4dc -r 6a035fab789a include/liblas/capi/liblas.h
--- a/include/liblas/capi/liblas.h	Wed Jun 22 10:32:44 2011 -0500
+++ b/include/liblas/capi/liblas.h	Wed Jun 22 10:47:01 2011 -0500
@@ -526,6 +526,12 @@
 */
 LAS_DLL LASError LASPoint_SetData(LASPointH hPoint, unsigned char* data);
 
+
+/** Returns an XMLized representation of the point
+ *  @param hPoint the LASPointH instance
+*/
+LAS_DLL char* LASPoint_GetXML(const LASPointH hPoint);
+
 /****************************************************************************/
 /* Header operations                                                        */
 /****************************************************************************/
diff -r 452c693ee4dc -r 6a035fab789a python/liblas/core.py
--- a/python/liblas/core.py	Wed Jun 22 10:32:44 2011 -0500
+++ b/python/liblas/core.py	Wed Jun 22 10:47:01 2011 -0500
@@ -241,7 +241,6 @@
 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
@@ -334,6 +333,10 @@
 las.LASPoint_GetPointSourceId.argtypes = [ctypes.c_void_p]
 las.LASPoint_GetPointSourceId.errcheck = check_value
 
+las.LASPoint_GetXML.restype = ctypes.POINTER(ctypes.c_char)
+las.LASPoint_GetXML.argtypes = [ctypes.c_void_p]
+las.LASPoint_GetXML.errcheck = free_returned_char_p
+
 # las.LASPoint_GetExtraData.argtypes = [ctypes.c_void_p,
 #                             ctypes.POINTER(ctypes.POINTER(ctypes.c_ubyte)),
 #                             ctypes.POINTER(ctypes.c_int)]
diff -r 452c693ee4dc -r 6a035fab789a python/liblas/point.py
--- a/python/liblas/point.py	Wed Jun 22 10:32:44 2011 -0500
+++ b/python/liblas/point.py	Wed Jun 22 10:47:01 2011 -0500
@@ -548,6 +548,13 @@
     def set_header(self, value):
         return core.las.LASPoint_SetHeader(self.handle, value.handle)
     header = property(get_header, set_header, None, None)
+
+
+    def get_xml(self):
+        return core.las.LASPoint_GetXML(self.handle)
+        
+    xml = property(get_xml, None, None, None)
+    
     # def descale(self, header):
     #     """Descales the point with a given :obj:`liblas.header.Header` instance
     # 
diff -r 452c693ee4dc -r 6a035fab789a python/tests/Point.txt
--- a/python/tests/Point.txt	Wed Jun 22 10:32:44 2011 -0500
+++ b/python/tests/Point.txt	Wed Jun 22 10:47:01 2011 -0500
@@ -101,6 +101,11 @@
   >>> p.color.red
   124
 
+  >>> p.xml
+  '<?xml version="1.0" encoding="utf-8"?>\n<x>1</x><y>2</y><z>3</z><rawx>100</rawx><rawy>200</rawy><rawz>300</rawz><time>1205988345.013434</time><intensity>120</intensity><returnnumber>3</returnnumber><numberofreturns>4</numberofreturns><scandirection>0</scandirection><scanangle>45</scanangle><flightlineedge>1</flightlineedge><userdata>163</userdata><pointsourceid>0</pointsourceid><classification><name>Low Vegetation</name><id>3</id><withheld>false</withheld><keypoint>false</keypoint><synthetic>false</synthetic></classification><color><red>124</red><green>0</green><blue>0</blue></color>'
+  
+
+
 
 #   
 #   >>> import ctypes
diff -r 452c693ee4dc -r 6a035fab789a src/c_api.cpp
--- a/src/c_api.cpp	Wed Jun 22 10:32:44 2011 -0500
+++ b/src/c_api.cpp	Wed Jun 22 10:47:01 2011 -0500
@@ -55,6 +55,7 @@
 #include <liblas/detail/reader/reader.hpp>
 #include <liblas/detail/reader/zipreader.hpp>
 #include <liblas/detail/reader/cachedreader.hpp>
+#include <liblas/external/property_tree/xml_parser.hpp>
 
 typedef struct LASWriterHS *LASWriterH;
 typedef struct LASReaderHS *LASReaderH;
@@ -974,6 +975,19 @@
     return value;
 }
 
+LAS_DLL char* LASPoint_GetXML(const LASPointH hPoint) 
+{
+    VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetXML", NULL);
+    liblas::Point* p = (liblas::Point*)hPoint;
+    
+    std::ostringstream oss;
+    
+    liblas::property_tree::ptree tree= p->GetPTree();
+    liblas::property_tree::write_xml(oss, tree);
+    return LASCopyString(oss.str().c_str());
+    
+}
+
 LAS_DLL LASErrorEnum LASPoint_SetUserData(LASPointH hPoint, boost::uint8_t value) {
 
     VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetUserData", LE_Failure);
diff -r 452c693ee4dc -r 6a035fab789a src/point.cpp
--- a/src/point.cpp	Wed Jun 22 10:32:44 2011 -0500
+++ b/src/point.cpp	Wed Jun 22 10:47:01 2011 -0500
@@ -314,6 +314,10 @@
     pt.put("y", GetY());
     pt.put("z", GetZ());
 
+    pt.put("rawx", GetRawX());
+    pt.put("rawy", GetRawY());
+    pt.put("rawz", GetRawZ());
+    
     pt.put("time", GetTime());
     pt.put("intensity", GetIntensity());
     pt.put("returnnumber", GetReturnNumber());


More information about the Liblas-commits mailing list