[Liblas-commits] hg: add LASReader_GetSummaryXML method to C and
Python APIs #236
liblas-commits at liblas.org
liblas-commits at liblas.org
Thu Jun 23 12:48:55 EDT 2011
details: http://hg.liblas.orghg/rev/b010a1523102
changeset: 3002:b010a1523102
user: Howard Butler <hobu.inc at gmail.com>
date: Thu Jun 23 11:48:49 2011 -0500
description:
add LASReader_GetSummaryXML method to C and Python APIs #236
diffstat:
include/liblas/capi/liblas.h | 2 ++
python/liblas/core.py | 4 ++++
python/liblas/file.py | 13 +++++++++++++
src/c_api.cpp | 31 +++++++++++++++++++++++++++++++
4 files changed, 50 insertions(+), 0 deletions(-)
diffs (95 lines):
diff -r 9d11e09e3dad -r b010a1523102 include/liblas/capi/liblas.h
--- a/include/liblas/capi/liblas.h Thu Jun 23 10:43:33 2011 -0500
+++ b/include/liblas/capi/liblas.h Thu Jun 23 11:48:49 2011 -0500
@@ -208,6 +208,7 @@
*/
LAS_DLL LASError LASReader_Seek(LASReaderH hReader, unsigned int position);
+LAS_DLL char* LASReader_GetSummaryXML(const LASReaderH hReader);
/****************************************************************************/
/* Point operations */
@@ -909,6 +910,7 @@
* @param hHeader the LASHeader instance
*/
LAS_DLL char* LASHeader_GetXML(const LASHeaderH hHeader);
+
/****************************************************************************/
/* Writer Operations */
/****************************************************************************/
diff -r 9d11e09e3dad -r b010a1523102 python/liblas/core.py
--- a/python/liblas/core.py Thu Jun 23 10:43:33 2011 -0500
+++ b/python/liblas/core.py Thu Jun 23 11:48:49 2011 -0500
@@ -208,6 +208,10 @@
las.LASReader_SetOutputSRS.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
las.LASReader_SetOutputSRS.errcheck = check_return
+las.LASReader_GetSummaryXML.restype = ctypes.POINTER(ctypes.c_char)
+las.LASReader_GetSummaryXML.argtypes = [ctypes.c_void_p]
+las.LASReader_GetSummaryXML.errcheck = free_returned_char_p
+
las.LASReader_Destroy.argtypes = [ctypes.c_void_p]
las.LASReader_Destroy.errcheck = check_void_done
las.LASReader_Destroy.restype = None
diff -r 9d11e09e3dad -r b010a1523102 python/liblas/file.py
--- a/python/liblas/file.py Thu Jun 23 10:43:33 2011 -0500
+++ b/python/liblas/file.py Thu Jun 23 11:48:49 2011 -0500
@@ -380,3 +380,16 @@
'be of type liblas.point.Point' % pt)
if self.mode == 1 or self.mode == 2:
core.las.LASWriter_WritePoint(self.handle, pt.handle)
+
+ def get_xmlsummary(self):
+ """Returns an XML string summarizing all of the points in the reader
+
+ .. note::
+ This method will reset the reader's read position to the 0th
+ point to summarize the entire file, and it will again reset the
+ read position to the 0th point upon completion."""
+ if self.mode != 0:
+ raise core.LASException("file must be in read mode, not append or write mode to provide xml summary")
+ return core.las.LASReader_GetSummaryXML(self.handle)
+
+ summary = property(get_xmlsummary, None, None, None)
\ No newline at end of file
diff -r 9d11e09e3dad -r b010a1523102 src/c_api.cpp
--- a/src/c_api.cpp Thu Jun 23 10:43:33 2011 -0500
+++ b/src/c_api.cpp Thu Jun 23 11:48:49 2011 -0500
@@ -394,6 +394,37 @@
}
+LAS_DLL char* LASReader_GetSummaryXML(const LASReaderH hReader)
+{
+
+ VALIDATE_LAS_POINTER1(hReader, "LASReader_GetSummaryXML", NULL);
+ liblas::Reader* r = (liblas::Reader*)hReader;
+ liblas::Summary s;
+
+ r->Reset();
+ bool read = r->ReadNextPoint();
+ if (!read)
+ {
+ LASError_PushError(LE_Failure, "Unable to read point", "LASReader_GetSummaryXML");
+ return NULL;
+ }
+
+ while (read)
+ {
+ liblas::Point const& p = r->GetPoint();
+ s.AddPoint(p);
+ read = r->ReadNextPoint();
+ }
+
+ r->Reset();
+
+ std::ostringstream oss;
+
+ liblas::property_tree::write_xml(oss, s.GetPTree());
+ return LASCopyString(oss.str().c_str());
+
+}
+
LAS_DLL LASErrorEnum LASReader_SetInputSRS(LASReaderH hReader, const LASSRSH hSRS) {
VALIDATE_LAS_POINTER1(hReader, "LASReader_SetInputSRS", LE_Failure);
More information about the Liblas-commits
mailing list