[Liblas-commits] hg: 3 new changesets

liblas-commits at liblas.org liblas-commits at liblas.org
Sun Oct 10 01:18:22 EDT 2010


changeset 02935c527273 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=02935c527273
summary: remove VLR summary from header output.  User should loop through the VLRs and output them to the ostream if they want

changeset 32dbaa0b26ac in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=32dbaa0b26ac
summary: support setting SystemID and SoftwareID, move a few functions into kernel

changeset 6d082929d60e in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=6d082929d60e
summary: start on lasinfo2

diffstat:

 apps/CMakeLists.txt                  |    8 +-
 apps/las2las2.cpp                    |   85 --------------
 apps/lasinfo2.cpp                    |  205 +++++++++++++++++++++++++++++++++++
 apps/laskernel.cpp                   |  113 +++++++++++++++++++-
 apps/laskernel.hpp                   |    3 +
 include/liblas/lasvariablerecord.hpp |    3 +
 include/liblas/utility.hpp           |   11 +-
 src/lasheader.cpp                    |   48 ++++----
 src/lasvariablerecord.cpp            |   18 +++
 src/utility.cpp                      |   51 ++++++++
 10 files changed, 429 insertions(+), 116 deletions(-)

diffs (truncated from 697 to 300 lines):

diff -r 78a0c6ee1dab -r 6d082929d60e apps/CMakeLists.txt
--- a/apps/CMakeLists.txt	Sat Oct 09 22:44:31 2010 -0500
+++ b/apps/CMakeLists.txt	Sun Oct 10 00:18:09 2010 -0500
@@ -20,6 +20,7 @@
 set(LAS2TXT las2txt)
 set(TXT2LAS txt2las)
 set(LAS2LAS2 las2las2 )
+set(LASINFO2 lasinfo2)
 set(LASBLOCK lasblock )
 
 set(BIGFILE_TEST bigfile_test)
@@ -42,7 +43,7 @@
 
 set(LIBLAS_UTILITIES
     ${LASINFO} ${LASMERGE} ${LAS2LAS} ${LAS2TXT} ${TXT2LAS} 
-    ${LAS2OGR}  ${LAS2OCI} ${LAS2LAS2} ${LASBLOCK})
+    ${LAS2OGR}  ${LAS2OCI} ${LAS2LAS2} ${LASBLOCK} ${LASINFO2})
 
 # TODO: Experimental and requires testing --mloskot
 # Generate user-specific settings for Visual Studio project
@@ -89,6 +90,11 @@
     target_link_libraries(${LAS2LAS2} ${APPS_CPP_DEPENDENCIES} ${Boost_LIBRARIES})
 endif()
 
+if(LASINFO2)
+    add_executable(${LASINFO2} lasinfo2.cpp laskernel.cpp)
+    target_link_libraries(${LASINFO2} ${APPS_CPP_DEPENDENCIES} ${Boost_LIBRARIES})
+endif()
+
 # Build las2txt
 if(LAS2TXT)
     set(LAS2TXT_SRC lascommon.c ${LAS2TXT}.c)
diff -r 78a0c6ee1dab -r 6d082929d60e apps/las2las2.cpp
--- a/apps/las2las2.cpp	Sat Oct 09 22:44:31 2010 -0500
+++ b/apps/las2las2.cpp	Sun Oct 10 00:18:09 2010 -0500
@@ -37,91 +37,6 @@
 }
 
 
-void RepairHeader(liblas::Summary const& summary, std::string const& filename)
-{
-    std::ifstream ifs;
-    if (!liblas::Open(ifs, filename.c_str()))
-    {
-        std::ostringstream oss;
-        oss << "Cannot open " << filename << "for read.  Exiting...";
-        throw std::runtime_error(oss.str());
-    }
-    liblas::Reader reader(ifs);
-    liblas::Header header = reader.GetHeader();
-    ifs.close();
-
-    for (boost::uint32_t i = 0; i < 5; i++)
-    {
-        header.SetPointRecordsByReturnCount(i, 0);
-    }    
-
-    std::ios::openmode m = std::ios::out | std::ios::in | std::ios::binary | std::ios::ate;
-
-    // Write a blank PointRecordsByReturnCount first
-    std::ofstream ofs(filename.c_str(), m);
-    liblas::Writer writer(ofs, header);
-    ofs.close();
-    
-    liblas::property_tree::ptree tree = summary.GetPTree();
-    
-    try
-    {
-        header.SetMin(tree.get<double>("minimum.x"),
-                      tree.get<double>("minimum.y"),
-                      tree.get<double>("minimum.z"));
-    
-        header.SetMax(tree.get<double>("maximum.x"),
-                      tree.get<double>("maximum.y"),
-                      tree.get<double>("maximum.z"));
-        
-    }     catch (liblas::property_tree::ptree_bad_path const& e) 
-    {
-        std::cerr << "Unable to write header bounds info.  Does the outputted file have any points?";
-        return;
-    }
-
-    try
-    {
-
-        for (boost::uint32_t i = 0; i < 5; i++)
-        {
-            header.SetPointRecordsByReturnCount(i, 0);
-        }
-    
-        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);        
-        } 
-        
-    }     catch (liblas::property_tree::ptree_bad_path const& e) 
-    {
-        std::cerr << "Unable to write header point return count info.  Does the outputted file have any points?";
-        return;
-    }
-    
-    
-    // Write our updated header with summary info
-    std::ofstream ofs2(filename.c_str(), m);
-    liblas::Writer writer2(ofs2, header);
-    ofs2.close();
-    
-}
-
-void SetStreamPrecision(std::ostream& os, double scale)
-{
-    os.setf(std::ios_base::fixed, std::ios_base::floatfield);
-
-    double frac = 0;
-    double integer = 0;
-    frac = std::modf(scale, &integer);
-
-    boost::uint32_t prec = static_cast<boost::uint32_t>(std::fabs(std::floor(std::log10(frac))));
-    os.precision(prec);    
-}
-
 bool process(   std::string const& input,
                 std::string const& output,
                 liblas::Header & header,
diff -r 78a0c6ee1dab -r 6d082929d60e apps/lasinfo2.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/apps/lasinfo2.cpp	Sun Oct 10 00:18:09 2010 -0500
@@ -0,0 +1,205 @@
+/***************************************************************************
+ *
+ * Project: libLAS -- C/C++ read/write library for LAS LIDAR data
+ * Purpose: LAS information with optional configuration
+ * Author:  Howard Butler, hobu.inc at gmail.com
+ ***************************************************************************
+ * Copyright (c) 2010, Howard Butler, hobu.inc at gmail.com 
+ *
+ * See LICENSE.txt in this source distribution for more information.
+ **************************************************************************/
+
+#include <liblas/liblas.hpp>
+#include "laskernel.hpp"
+
+#include <boost/cstdint.hpp>
+#include <boost/foreach.hpp>
+
+
+using namespace liblas;
+using namespace std;
+
+
+liblas::Summary check_points(   liblas::Reader& reader,
+                                std::vector<liblas::FilterPtr>& filters,
+                                std::vector<liblas::TransformPtr>& transforms,
+                                bool verbose)
+{
+
+    liblas::Summary summary;
+    
+    reader.SetFilters(filters);
+    reader.SetTransforms(transforms);
+
+
+
+    if (verbose)
+    std::cout << "Scanning points:" 
+        << "\n - : "
+        << std::endl;
+
+    //
+    // Translation of points cloud to features set
+    //
+    boost::uint32_t i = 0;
+    boost::uint32_t const size = reader.GetHeader().GetPointRecordsCount();
+    
+
+    while (reader.ReadNextPoint())
+    {
+        liblas::Point const& p = reader.GetPoint();
+        summary.AddPoint(p);
+        if (verbose)
+            term_progress(std::cout, (i + 1) / static_cast<double>(size));
+        i++;
+
+    }
+    if (verbose)
+        std::cout << std::endl;
+    
+    return summary;
+    
+}
+
+void OutputHelp( std::ostream & oss, po::options_description const& options)
+{
+    oss << "--------------------------------------------------------------------\n";
+    oss << "    lasinfo2 (" << GetFullVersion() << ")\n";
+    oss << "--------------------------------------------------------------------\n";
+
+    oss << options;
+
+    oss <<"\nFor more information, see the full documentation for lasinfo2 at:\n";
+    
+    oss << " http://liblas.org/utilities/lasinfo2.html\n";
+    oss << "----------------------------------------------------------\n";
+
+}
+
+void PrintVLRs(std::ostream& os, liblas::Header& header)
+{
+    if (!header.GetRecordsCount())
+        return ;
+        
+    os << "---------------------------------------------------------" << std::endl;
+    os << "  VLR Summary" << std::endl;
+    os << "---------------------------------------------------------" << std::endl;
+    
+    typedef std::vector<VariableRecord>::size_type size_type;
+    for(size_type i = 0; i < header.GetRecordsCount(); i++) {
+        liblas::VariableRecord const& v = header.GetVLR(i);
+        os << v;
+    }
+    os << std::endl;
+    
+}
+int main(int argc, char* argv[])
+{
+
+    std::string input;
+
+    bool verbose = false;
+    bool check = true;
+    bool show_vlrs = true;
+    
+    std::vector<liblas::FilterPtr> filters;
+    std::vector<liblas::TransformPtr> transforms;
+    
+    liblas::Header header;
+
+    try {
+
+        po::options_description file_options("lasinfo2 options");
+        po::options_description filtering_options = GetFilteringOptions();
+        po::options_description header_options = GetHeaderOptions();
+
+        po::positional_options_description p;
+        p.add("input", 1);
+        p.add("output", 1);
+
+        file_options.add_options()
+            ("help,h", "produce help message")
+            ("input,i", po::value< string >(), "input LAS file")
+
+            ("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-check", po::value<bool>(&check)->zero_tokens()->implicit_value(false), "Don't scan points")
+
+        ;
+
+        po::variables_map vm;
+        po::options_description options;
+        options.add(file_options).add(filtering_options);
+        po::store(po::command_line_parser(argc, argv).
+          options(options).positional(p).run(), vm);
+
+        po::notify(vm);
+
+        if (vm.count("help")) 
+        {
+            OutputHelp(std::cout, options);
+            return 1;
+        }
+
+
+        if (vm.count("input")) 
+        {
+            input = vm["input"].as< string >();
+            std::ifstream ifs;
+            if (verbose)
+                std::cout << "Opening " << input << " to fetch Header" << std::endl;
+            if (!liblas::Open(ifs, input.c_str()))
+            {
+                std::cerr << "Cannot open " << input << "for read.  Exiting...";
+                return 1;
+            }
+            liblas::Reader reader(ifs);
+            header = reader.GetHeader();
+        } else {
+            std::cerr << "Input LAS file not specified!\n";
+            OutputHelp(std::cout, options);
+            return 1;
+        }
+
+
+        filters = GetFilters(vm, verbose);
+
+        std::ifstream ifs;
+        if (!liblas::Open(ifs, input.c_str()))
+        {


More information about the Liblas-commits mailing list