[Liblas-commits] hg-main-tree: added stage-specific stage dumping to pcinfo

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Aug 18 20:44:47 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/a5c850699fc4
changeset: 1144:a5c850699fc4
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Aug 18 17:44:29 2011 -0700
description:
added stage-specific stage dumping to pcinfo

diffstat:

 apps/pcinfo.cpp                            |   7 +---
 include/pdal/Filter.hpp                    |   4 +++
 include/pdal/MultiFilter.hpp               |   4 +++
 include/pdal/Reader.hpp                    |   4 +++
 include/pdal/Stage.hpp                     |   3 +-
 include/pdal/StageBase.hpp                 |   1 +
 include/pdal/Writer.hpp                    |   4 +++
 include/pdal/drivers/faux/Reader.hpp       |   3 ++
 include/pdal/drivers/faux/Writer.hpp       |   3 ++
 include/pdal/drivers/las/Reader.hpp        |   3 ++
 include/pdal/drivers/las/Writer.hpp        |   3 ++
 include/pdal/drivers/liblas/Reader.hpp     |   3 ++
 include/pdal/drivers/liblas/Writer.hpp     |   5 +++-
 include/pdal/drivers/oci/Reader.hpp        |   3 ++
 include/pdal/drivers/oci/Writer.hpp        |   3 +-
 include/pdal/drivers/pipeline/Reader.hpp   |   3 ++
 include/pdal/drivers/qfit/Reader.hpp       |   2 +
 include/pdal/drivers/terrasolid/Reader.hpp |   2 +
 src/Filter.cpp                             |  10 +++++++
 src/MultiFilter.cpp                        |  10 +++++++
 src/Reader.cpp                             |  10 +++++++
 src/Stage.cpp                              |  11 ++++++-
 src/Writer.cpp                             |  10 +++++++
 src/drivers/faux/Reader.cpp                |  10 +++++++
 src/drivers/faux/Writer.cpp                |   9 ++++++
 src/drivers/las/Reader.cpp                 |  10 +++++++
 src/drivers/las/Writer.cpp                 |  10 +++++++
 src/drivers/liblas/Reader.cpp              |   9 ++++++
 src/drivers/liblas/Writer.cpp              |  10 +++++++
 src/drivers/oci/Reader.cpp                 |   9 ++++++
 src/drivers/oci/Writer.cpp                 |   9 ++++++
 src/drivers/pipeline/Reader.cpp            |   9 ++++++
 src/drivers/qfit/Reader.cpp                |   8 ++++++
 src/drivers/terrasolid/Reader.cpp          |   7 +++++
 src/filters/StatsFilter.cpp                |  16 +++++++----
 test/data/apps/pcinfo_stage.txt            |  40 +++++++++++++++++++++++++++--
 test/unit/StatsFilterTest.cpp              |   3 +-
 test/unit/pcinfoTest.cpp                   |   2 +
 38 files changed, 251 insertions(+), 21 deletions(-)

diffs (truncated from 644 to 300 lines):

diff -r acc2c512e52c -r a5c850699fc4 apps/pcinfo.cpp
--- a/apps/pcinfo.cpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/apps/pcinfo.cpp	Thu Aug 18 17:44:29 2011 -0700
@@ -206,14 +206,11 @@
 
 void PcInfo::dumpStage(const Stage& stage) const
 {
-    const boost::uint64_t numPoints = stage.getNumPoints();
-    const SpatialReference& srs = stage.getSpatialReference();
+    boost::property_tree::ptree tree = stage.toPTree();
 
     std::ostream& ostr = m_outputStream ? *m_outputStream : std::cout;
 
-    ostr << "driver type: " << stage.getName() << "\n";
-    ostr << numPoints << " points\n";
-    ostr << "WKT: " << srs.getWKT() << "\n";
+    boost::property_tree::write_json(ostr, tree);
 
     return;
 }
diff -r acc2c512e52c -r a5c850699fc4 include/pdal/Filter.hpp
--- a/include/pdal/Filter.hpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/include/pdal/Filter.hpp	Thu Aug 18 17:44:29 2011 -0700
@@ -51,8 +51,12 @@
 
     const Stage& getPrevStage() const;
 
+    // for xml serializion of pipelines
     virtual boost::property_tree::ptree generatePTree() const;
 
+    // for dumping
+    virtual boost::property_tree::ptree toPTree() const;
+
 protected:
     Stage& getPrevStage();
 
diff -r acc2c512e52c -r a5c850699fc4 include/pdal/MultiFilter.hpp
--- a/include/pdal/MultiFilter.hpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/include/pdal/MultiFilter.hpp	Thu Aug 18 17:44:29 2011 -0700
@@ -53,8 +53,12 @@
 
     const std::vector<const Stage*> getPrevStages() const;
 
+    // for xml serializion of pipelines
     virtual boost::property_tree::ptree generatePTree() const;
 
+    // for dumping
+    virtual boost::property_tree::ptree toPTree() const;
+
 protected:
     std::vector<Stage*> m_prevStages;
 
diff -r acc2c512e52c -r a5c850699fc4 include/pdal/Reader.hpp
--- a/include/pdal/Reader.hpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/include/pdal/Reader.hpp	Thu Aug 18 17:44:29 2011 -0700
@@ -54,7 +54,11 @@
 
     virtual void initialize();
 
+    // for xml serializion of pipelines
     virtual boost::property_tree::ptree generatePTree() const;
+    
+    // for dumping
+    virtual boost::property_tree::ptree toPTree() const;
 };
 
 } // namespace pdal
diff -r acc2c512e52c -r a5c850699fc4 include/pdal/Stage.hpp
--- a/include/pdal/Stage.hpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/include/pdal/Stage.hpp	Thu Aug 18 17:44:29 2011 -0700
@@ -76,7 +76,8 @@
     virtual StageRandomIterator* createRandomIterator() const  { return NULL; }
     virtual StageBlockIterator* createBlockIterator() const  { return NULL; }
 
-    void dump() const;
+    // for dumping
+    virtual boost::property_tree::ptree toPTree() const;
     
 protected:
     // setters for the core properties
diff -r acc2c512e52c -r a5c850699fc4 include/pdal/StageBase.hpp
--- a/include/pdal/StageBase.hpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/include/pdal/StageBase.hpp	Thu Aug 18 17:44:29 2011 -0700
@@ -106,6 +106,7 @@
     static std::string s_getDescription() { return description; }  \
     std::string getDescription() const { return description; }
 
+    // for dumping
     virtual boost::property_tree::ptree toPTree() const;
     virtual void dump() const;
 
diff -r acc2c512e52c -r a5c850699fc4 include/pdal/Writer.hpp
--- a/include/pdal/Writer.hpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/include/pdal/Writer.hpp	Thu Aug 18 17:44:29 2011 -0700
@@ -65,6 +65,7 @@
     // If given number of points is 0, do as many points as the reader supplies to us.
     boost::uint64_t write(boost::uint64_t targetNumPointsToWrite=0);
 
+    // for xml serializion of pipelines
     virtual boost::property_tree::ptree generatePTree() const;
 
     const Stage& getPrevStage() const;
@@ -72,6 +73,9 @@
     const SpatialReference& getSpatialReference() const;
     void setSpatialReference(const SpatialReference&);
 
+    // for dumping
+    virtual boost::property_tree::ptree toPTree() const;
+
 protected:
     // this is called once before the loop with all the writeBuffer calls
     virtual void writeBegin(boost::uint64_t targetNumPointsToWrite) = 0;
diff -r acc2c512e52c -r a5c850699fc4 include/pdal/drivers/faux/Reader.hpp
--- a/include/pdal/drivers/faux/Reader.hpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/include/pdal/drivers/faux/Reader.hpp	Thu Aug 18 17:44:29 2011 -0700
@@ -99,6 +99,9 @@
     // this is called by the stage's iterator
     boost::uint32_t processBuffer(PointBuffer& data, boost::uint64_t index) const;
 
+    // for dumping
+    virtual boost::property_tree::ptree toPTree() const;
+
 private:
     Bounds<double> m_bounds;
     boost::uint64_t m_numPoints;
diff -r acc2c512e52c -r a5c850699fc4 include/pdal/drivers/faux/Writer.hpp
--- a/include/pdal/drivers/faux/Writer.hpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/include/pdal/drivers/faux/Writer.hpp	Thu Aug 18 17:44:29 2011 -0700
@@ -70,6 +70,9 @@
     double getAvgY() const { return m_averageY; }
     double getAvgZ() const { return m_averageZ; }
 
+    // for dumping
+    virtual boost::property_tree::ptree toPTree() const;
+
 private:
     double m_minimumX;
     double m_minimumY;
diff -r acc2c512e52c -r a5c850699fc4 include/pdal/drivers/las/Reader.hpp
--- a/include/pdal/drivers/las/Reader.hpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/include/pdal/drivers/las/Reader.hpp	Thu Aug 18 17:44:29 2011 -0700
@@ -94,6 +94,9 @@
 
     bool isCompressed() const;
 
+    // for dumping
+    virtual boost::property_tree::ptree toPTree() const;
+
 protected:
     const LasHeader& getLasHeader() const { return m_lasHeader; }
     LasHeader& getLasHeaderRef() { return m_lasHeader; }
diff -r acc2c512e52c -r a5c850699fc4 include/pdal/drivers/las/Writer.hpp
--- a/include/pdal/drivers/las/Writer.hpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/include/pdal/drivers/las/Writer.hpp	Thu Aug 18 17:44:29 2011 -0700
@@ -88,6 +88,9 @@
     // default false
     void setCompressed(bool);
 
+    // for dumping
+    virtual boost::property_tree::ptree toPTree() const;
+
 protected:
     virtual void writeBegin(boost::uint64_t targetNumPointsToWrite);
     virtual boost::uint32_t writeBuffer(const PointBuffer&);
diff -r acc2c512e52c -r a5c850699fc4 include/pdal/drivers/liblas/Reader.hpp
--- a/include/pdal/drivers/liblas/Reader.hpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/include/pdal/drivers/liblas/Reader.hpp	Thu Aug 18 17:44:29 2011 -0700
@@ -88,6 +88,9 @@
     pdal::StageSequentialIterator* createSequentialIterator() const;
     pdal::StageRandomIterator* createRandomIterator() const;
 
+    // for dumping
+    virtual boost::property_tree::ptree toPTree() const;
+
 private:
     void processExternalHeader(::liblas::Reader& externalReader);
     void registerFields(::liblas::Reader& externalReader);
diff -r acc2c512e52c -r a5c850699fc4 include/pdal/drivers/liblas/Writer.hpp
--- a/include/pdal/drivers/liblas/Writer.hpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/include/pdal/drivers/liblas/Writer.hpp	Thu Aug 18 17:44:29 2011 -0700
@@ -88,7 +88,10 @@
     void setCompressed(bool);
     
     void setHeaderPadding(boost::uint32_t const& v);
-    
+
+    // for dumping
+    virtual boost::property_tree::ptree toPTree() const;
+
 protected:
     virtual void writeBegin(boost::uint64_t targetNumPointsToWrite);
     virtual boost::uint32_t writeBuffer(const PointBuffer&);
diff -r acc2c512e52c -r a5c850699fc4 include/pdal/drivers/oci/Reader.hpp
--- a/include/pdal/drivers/oci/Reader.hpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/include/pdal/drivers/oci/Reader.hpp	Thu Aug 18 17:44:29 2011 -0700
@@ -75,6 +75,9 @@
     CloudPtr getCloud() const;
     std::string getQuery() const;
 
+    // for dumping
+    virtual boost::property_tree::ptree toPTree() const;
+
 private:
 
     Reader& operator=(const Reader&); // not implemented
diff -r acc2c512e52c -r a5c850699fc4 include/pdal/drivers/oci/Writer.hpp
--- a/include/pdal/drivers/oci/Writer.hpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/include/pdal/drivers/oci/Writer.hpp	Thu Aug 18 17:44:29 2011 -0700
@@ -64,7 +64,8 @@
     
     inline Connection getConnection() const { return m_connection;}
 
-
+        // for dumping
+    virtual boost::property_tree::ptree toPTree() const;
 
 protected:
     virtual void writeBegin(boost::uint64_t targetNumPointsToWrite);
diff -r acc2c512e52c -r a5c850699fc4 include/pdal/drivers/pipeline/Reader.hpp
--- a/include/pdal/drivers/pipeline/Reader.hpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/include/pdal/drivers/pipeline/Reader.hpp	Thu Aug 18 17:44:29 2011 -0700
@@ -63,6 +63,9 @@
     // this is called by the stage's iterator
     boost::uint32_t processBuffer(PointBuffer& data, boost::uint64_t index) const;
 
+    // for dumping
+    virtual boost::property_tree::ptree toPTree() const;
+
 private:
     std::string m_filename;
     boost::scoped_ptr<PipelineManager> m_manager;
diff -r acc2c512e52c -r a5c850699fc4 include/pdal/drivers/qfit/Reader.hpp
--- a/include/pdal/drivers/qfit/Reader.hpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/include/pdal/drivers/qfit/Reader.hpp	Thu Aug 18 17:44:29 2011 -0700
@@ -153,6 +153,8 @@
     // this is called by the stage's iterator
     boost::uint32_t processBuffer(PointBuffer& PointBuffer, std::istream& stream, boost::uint64_t numPointsLeft) const;
 
+    // for dumping
+    virtual boost::property_tree::ptree toPTree() const;
 
 protected:
     inline QFIT_Format_Type getFormat() const { return m_format; }
diff -r acc2c512e52c -r a5c850699fc4 include/pdal/drivers/terrasolid/Reader.hpp
--- a/include/pdal/drivers/terrasolid/Reader.hpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/include/pdal/drivers/terrasolid/Reader.hpp	Thu Aug 18 17:44:29 2011 -0700
@@ -165,6 +165,8 @@
     // this is called by the stage's iterator
     boost::uint32_t processBuffer(PointBuffer& PointBuffer, std::istream& stream, boost::uint64_t numPointsLeft) const;
 
+    // for dumping
+    virtual boost::property_tree::ptree toPTree() const;
 
 protected:
     inline TERRASOLID_Format_Type getFormat() const { return m_format; }
diff -r acc2c512e52c -r a5c850699fc4 src/Filter.cpp
--- a/src/Filter.cpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/src/Filter.cpp	Thu Aug 18 17:44:29 2011 -0700
@@ -93,4 +93,14 @@
 }
 
 
+boost::property_tree::ptree Filter::toPTree() const
+{
+    boost::property_tree::ptree tree = Stage::toPTree();
+
+    // (nothing to add for a Filter)
+
+    return tree;
+}
+
+
 } // namespace pdal
diff -r acc2c512e52c -r a5c850699fc4 src/MultiFilter.cpp
--- a/src/MultiFilter.cpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/src/MultiFilter.cpp	Thu Aug 18 17:44:29 2011 -0700
@@ -107,4 +107,14 @@
 }
 
 
+boost::property_tree::ptree MultiFilter::toPTree() const
+{
+    boost::property_tree::ptree tree = Stage::toPTree();
+
+    tree.add("NumPrevStages", getPrevStages().size());
+
+    return tree;
+}
+
+
 } // namespace pdal
diff -r acc2c512e52c -r a5c850699fc4 src/Reader.cpp
--- a/src/Reader.cpp	Thu Aug 18 17:06:52 2011 -0700
+++ b/src/Reader.cpp	Thu Aug 18 17:44:29 2011 -0700
@@ -74,4 +74,14 @@
 }
 
 
+boost::property_tree::ptree Reader::toPTree() const
+{


More information about the Liblas-commits mailing list