[Liblas-commits] hg: add the ability to lasinfo to display the values of a specif...

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Oct 28 14:59:53 EDT 2010


changeset 9178ecb2d62e in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=9178ecb2d62e
summary: add the ability to lasinfo to display the values of a specific point in either a fixed format or xml

diffstat:

 apps/lasinfo.cpp |  36 +++++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)

diffs (67 lines):

diff -r 4c958bf3c1f1 -r 9178ecb2d62e apps/lasinfo.cpp
--- a/apps/lasinfo.cpp	Thu Oct 28 11:45:47 2010 -0500
+++ b/apps/lasinfo.cpp	Thu Oct 28 13:59:42 2010 -0500
@@ -105,6 +105,8 @@
     bool show_schema = true;
     bool output_xml = false;
     bool output_json = false;
+    bool show_point = false;
+    boost::uint32_t point = 0;
     
     std::vector<liblas::FilterPtr> filters;
     std::vector<liblas::TransformPtr> transforms;
@@ -130,6 +132,8 @@
             ("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")
+            ("point,p", po::value<boost::uint32_t>(&point), "Display a point with a given id.  --point 44")
+
             // ("json", po::value<bool>(&output_json)->zero_tokens()->implicit_value(true), "Output summary as JSON")
 
 // --xml
@@ -151,6 +155,10 @@
             return 1;
         }
 
+        if (vm.count("point")) 
+        {
+            show_point = true;
+        }
 
         if (vm.count("input")) 
         {
@@ -183,7 +191,33 @@
     
 
         liblas::Reader reader(ifs);
-        
+        if (show_point)
+        {
+            try 
+            {
+                reader.ReadPointAt(point);
+                liblas::Point const& p = reader.GetPoint();
+                if (output_xml) {
+                    liblas::property_tree::ptree tree;
+                    tree = p.GetPTree();
+                    liblas::property_tree::write_xml(std::cout, tree);
+                    exit(0);
+                } 
+                else 
+                {
+                    std::cout <<  p << std::endl;
+                    exit(0);    
+                }
+                
+            } catch (std::out_of_range const& e)
+            {
+                std::cerr << "Unable to read point at index " << point << ": " << e.what() << std::endl;
+                exit(1);
+                
+            }
+
+        }
+
         liblas::Summary summary;
         if (check)
             summary = check_points(  reader, 


More information about the Liblas-commits mailing list