[Liblas-commits] hg: complete lasinfo2

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Oct 12 12:43:47 EDT 2010


changeset d9fb3e27ffaa in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=d9fb3e27ffaa
summary: complete lasinfo2

diffstat:

 apps/las2las2.cpp               |   16 +-
 apps/lasinfo2.cpp               |   40 ++++++++-
 include/liblas/lasdimension.hpp |    4 +-
 src/lasdimension.cpp            |   45 ++++++++++
 src/lasheader.cpp               |    2 +
 src/lasschema.cpp               |   39 +++-----
 src/utility.cpp                 |  178 +++++++++++++++++++++++++++++++++++++--
 7 files changed, 273 insertions(+), 51 deletions(-)

diffs (truncated from 454 to 300 lines):

diff -r 5c3ee7cacba8 -r d9fb3e27ffaa apps/las2las2.cpp
--- a/apps/las2las2.cpp	Tue Oct 12 17:02:41 2010 +0100
+++ b/apps/las2las2.cpp	Tue Oct 12 11:43:39 2010 -0500
@@ -193,14 +193,14 @@
         std::cout << std::endl;
     
     reader.Reset();
-    liblas::property_tree::ptree pts = summary->GetPTree();
-    liblas::property_tree::ptree top;
-    top.add_child("summary.header",reader.GetHeader().GetPTree());
-    top.add_child("summary.points",pts);
-    liblas::property_tree::write_xml("junk.xml", top);
-    liblas::property_tree::write_xml("schema.xml", reader.GetHeader().GetSchema().GetPTree());
-
-    std::cout <<  reader.GetHeader().GetSchema() << std::endl;
+    // liblas::property_tree::ptree pts = summary->GetPTree();
+    // liblas::property_tree::ptree top;
+    // top.add_child("summary.header",reader.GetHeader().GetPTree());
+    // top.add_child("summary.points",pts);
+    // liblas::property_tree::write_xml("junk.xml", top);
+    // liblas::property_tree::write_xml("schema.xml", reader.GetHeader().GetSchema().GetPTree());
+    // 
+    // std::cout <<  reader.GetHeader().GetSchema() << std::endl;
     delete writer;
     delete ofs;
     
diff -r 5c3ee7cacba8 -r d9fb3e27ffaa apps/lasinfo2.cpp
--- a/apps/lasinfo2.cpp	Tue Oct 12 17:02:41 2010 +0100
+++ b/apps/lasinfo2.cpp	Tue Oct 12 11:43:39 2010 -0500
@@ -76,7 +76,7 @@
 
 }
 
-void PrintVLRs(std::ostream& os, liblas::Header& header)
+void PrintVLRs(std::ostream& os, liblas::Header const& header)
 {
     if (!header.GetRecordsCount())
         return ;
@@ -90,9 +90,10 @@
         liblas::VariableRecord const& v = header.GetVLR(i);
         os << v;
     }
-    os << std::endl;
     
 }
+
+
 int main(int argc, char* argv[])
 {
 
@@ -101,6 +102,9 @@
     bool verbose = false;
     bool check = true;
     bool show_vlrs = true;
+    bool show_schema = true;
+    bool output_xml = false;
+    bool output_json = false;
     
     std::vector<liblas::FilterPtr> filters;
     std::vector<liblas::TransformPtr> transforms;
@@ -123,8 +127,14 @@
 
             ("verbose,v", po::value<bool>(&verbose)->zero_tokens(), "Verbose message output")
             ("no-vlrs", po::value<bool>(&show_vlrs)->zero_tokens()->implicit_value(false), "Don't show VLRs")
+            ("no-schema", po::value<bool>(&show_schema)->zero_tokens()->implicit_value(false), "Don't show schema")
             ("no-check", po::value<bool>(&check)->zero_tokens()->implicit_value(false), "Don't scan points")
+            ("xml", po::value<bool>(&output_xml)->zero_tokens()->implicit_value(true), "Output summary as XML")
+            // ("json", po::value<bool>(&output_json)->zero_tokens()->implicit_value(true), "Output summary as JSON")
 
+// --xml
+// --json
+// --restructured text output
         ;
 
         po::variables_map vm;
@@ -182,12 +192,34 @@
                             verbose
                             );
 
-        liblas::Header header = reader.GetHeader();
-        std::cout << header << std::endl;
+        liblas::Header const& header = reader.GetHeader();
+
         
+        if (output_xml && output_json) {
+            std::cerr << "both JSON and XML output cannot be chosen";
+            return 1;
+        }
+        if (output_xml) {
+
+            liblas::property_tree::ptree tree = summary.GetPTree();
+            liblas::property_tree::write_xml(std::cout, tree);
+            return 0;
+        }
+
+        std::cout << header << std::endl;        
         if (show_vlrs)
             PrintVLRs(std::cout, header);
+
+        if (show_schema)
+            std::cout << header.GetSchema();
+                    
+        if (check) {
+            // Add the header to the summary so we can get more detailed 
+            // info
+            summary.SetHeader(header);
+            std::cout << summary << std::endl;
             
+        }
     }
     catch(std::exception& e) {
         std::cerr << "error: " << e.what() << "\n";
diff -r 5c3ee7cacba8 -r d9fb3e27ffaa include/liblas/lasdimension.hpp
--- a/include/liblas/lasdimension.hpp	Tue Oct 12 17:02:41 2010 +0100
+++ b/include/liblas/lasdimension.hpp	Tue Oct 12 11:43:39 2010 -0500
@@ -186,7 +186,8 @@
     {
         return m_position > dim.m_position;
     }
-    
+
+    liblas::property_tree::ptree GetPTree() const;
 private:
         
     std::string m_name;
@@ -235,6 +236,7 @@
     bool req_;
 };
 
+std::ostream& operator<<(std::ostream& os, liblas::Dimension const& d);
 
 } // namespace liblas
 
diff -r 5c3ee7cacba8 -r d9fb3e27ffaa src/lasdimension.cpp
--- a/src/lasdimension.cpp	Tue Oct 12 17:02:41 2010 +0100
+++ b/src/lasdimension.cpp	Tue Oct 12 11:43:39 2010 -0500
@@ -144,4 +144,49 @@
     return m_bit_size / 8;
 }
 
+liblas::property_tree::ptree Dimension::GetPTree() const
+{
+    using liblas::property_tree::ptree;
+    ptree dim;
+    dim.put("name", GetName());
+    dim.put("description", GetDescription());
+    dim.put("position", GetPosition());
+    dim.put("active", static_cast<boost::uint32_t>(IsActive()));
+    dim.put("size", GetBitSize());
+    dim.put("integer", static_cast<boost::uint32_t>(IsInteger()));
+    dim.put("signed", static_cast<boost::uint32_t>(IsSigned()));
+    dim.put("required", static_cast<boost::uint32_t>(IsRequired()));
+    dim.put("byteoffset", GetByteOffset());
+    dim.put("bitoffset" , GetBitOffset());
+    dim.put("bytesize", GetByteSize());
+    
+   if (IsNumeric()) {
+       if (! (detail::compare_distance(GetMinimum(), GetMaximum() ) 
+            && detail::compare_distance(0.0, GetMaximum())))
+       {
+           dim.put("minimum", GetMinimum());
+           dim.put("maximum", GetMaximum());
+       }
+    }
+    
+    return dim;
+}
+
+std::ostream& operator<<(std::ostream& os, liblas::Dimension const& d)
+{
+    
+    using liblas::property_tree::ptree;
+    ptree tree = d.GetPTree();
+    
+    std::string name = tree.get<std::string>("name");
+    
+
+    os << "'" << name << "'" << " -- ";
+    os << " size: " << tree.get<boost::uint32_t>("size");
+    os << " offset: " << tree.get<boost::uint32_t>("byteoffset");
+    os << std::endl;
+    
+    return os;
+}
+
 } // namespace liblas
diff -r 5c3ee7cacba8 -r d9fb3e27ffaa src/lasheader.cpp
--- a/src/lasheader.cpp	Tue Oct 12 17:02:41 2010 +0100
+++ b/src/lasheader.cpp	Tue Oct 12 11:43:39 2010 -0500
@@ -787,6 +787,8 @@
 
     using liblas::property_tree::ptree;
     ptree tree = GetPTree();
+
+    os << "---------------------------------------------------------" << std::endl;
     os << "  Header Summary" << std::endl;
     os << "---------------------------------------------------------" << std::endl;
     os << std::endl;
diff -r 5c3ee7cacba8 -r d9fb3e27ffaa src/lasschema.cpp
--- a/src/lasschema.cpp	Tue Oct 12 17:02:41 2010 +0100
+++ b/src/lasschema.cpp	Tue Oct 12 11:43:39 2010 -0500
@@ -464,28 +464,7 @@
     
     for(i = position_index.begin(); i != position_index.end(); ++i)
     {
-        ptree dim;
-        Dimension const& t = *i;
-        dim.put("name", t.GetName());
-        dim.put("description", t.GetDescription());
-        dim.put("position", t.GetPosition());
-        dim.put("active", static_cast<boost::uint32_t>(t.IsActive()));
-        dim.put("size", t.GetBitSize());
-        dim.put("integer", static_cast<boost::uint32_t>(t.IsInteger()));
-        dim.put("signed", static_cast<boost::uint32_t>(t.IsSigned()));
-        dim.put("required", static_cast<boost::uint32_t>(t.IsRequired()));
-
-       if (t.IsNumeric()) {
-           if (! (detail::compare_distance(t.GetMinimum(), t.GetMaximum() ) 
-                && detail::compare_distance(0.0, t.GetMaximum())))
-           {
-               dim.put("minimum", t.GetMinimum());
-               dim.put("maximum", t.GetMaximum());
-           }
-        }
-
-        pt.add_child("LASSchema.dimensions.dimension", dim);
-        
+        pt.add_child("LASSchema.dimensions.dimension", i->GetPTree());
     }
     
     pt.put("LASSchema.version", "1.0");
@@ -539,12 +518,22 @@
         os << "  Bit size is unaligned to byte boundaries" << std::endl;
     }
     
+    os << std::endl;
+    os << "  Dimensions" << std::endl;
+    os << "---------------------------------------------------------" << std::endl;
+    
     os << "  ";
-    for (i = dims.begin(); i != dims.end(); ++i)
+
+    index_by_position const& position_index = s.GetDimensions().get<position>();
+    index_by_position::const_iterator it;
+    
+    for(it = position_index.begin(); it != position_index.end(); ++it)
     {
-        std::string name = (*i).second.get<std::string>("name");
-        os << name << " ";
+        os << *it;
+        os << "  ";
     }
+    
+
     os << std::endl;
     
     return os;
diff -r 5c3ee7cacba8 -r d9fb3e27ffaa src/utility.cpp
--- a/src/utility.cpp	Tue Oct 12 17:02:41 2010 +0100
+++ b/src/utility.cpp	Tue Oct 12 11:43:39 2010 -0500
@@ -221,9 +221,9 @@
             pt.add_child("classification.classification",klasses);            
         }
     }
-    pt.put("classification.withheld", withheld);
-    pt.put("classification.keypoint", keypoint);
-    pt.put("classification.synthetic", synthetic);
+    pt.put("encoding.withheld", withheld);
+    pt.put("encoding.keypoint", keypoint);
+    pt.put("encoding.synthetic", synthetic);
     
     ptree returns;
     bool have_returns = false;
@@ -269,18 +269,170 @@
 {
     liblas::property_tree::ptree tree = s.GetPTree();
     
-    os << "---------------------------------------------------------";
-    os << "  Point Inspection Summary" ;
-    os << "---------------------------------------------------------";
+    os << "---------------------------------------------------------" << std::endl;
+    os << "  Point Inspection Summary" << std::endl;
+    os << "---------------------------------------------------------" << std::endl;
 
-        BOOST_FOREACH(ptree::value_type &v,
-                tree.get_child("points_by_return"))
-        {
-            boost::uint32_t i = v.second.get<boost::uint32_t>("id");
-            boost::uint32_t count = v.second.get<boost::uint32_t>("count");
-            // header.SetPointRecordsByReturnCount(i-1, count);        
-        }     
+    os << "  Header Point Count: " << tree.get<std::string>("summary.header.count") << std::endl;
+    os << "  Actual Point Count: " << tree.get<std::string>("summary.points.count") << std::endl;
+    
+    os << std::endl;
+    os << "  Minimum and Maximum Attributes (min,max)" << std::endl;
+    os << "---------------------------------------------------------" << std::endl;
+    
+    boost::uint32_t x_precision = 6;
+    boost::uint32_t y_precision = 6;


More information about the Liblas-commits mailing list