[Liblas-commits] hg-main-tree: move pipeline xml files into a subdir

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Aug 15 21:56:54 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/2b336b016482
changeset: 1105:2b336b016482
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Aug 15 17:21:47 2011 -0700
description:
move pipeline xml files into a subdir
Subject: hg-main-tree: use StageFactory now

details:   http://hg.libpc.orghg-main-tree/rev/d578a5bea239
changeset: 1106:d578a5bea239
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Aug 15 18:14:01 2011 -0700
description:
use StageFactory now
Subject: hg-main-tree: checkpoint for driver.pipeline.reader

details:   http://hg.libpc.orghg-main-tree/rev/730887bf9816
changeset: 1107:730887bf9816
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Aug 15 18:56:50 2011 -0700
description:
checkpoint for driver.pipeline.reader

diffstat:

 apps/AppSupport.cpp                           |   60 +++++------
 apps/AppSupport.hpp                           |   15 +--
 apps/pcinfo.cpp                               |  126 +++----------------------
 include/pdal/drivers/pipeline/Iterator.hpp    |   79 ++++++++++++++++
 include/pdal/drivers/pipeline/Reader.hpp      |   85 +++++++++++++++++
 src/CMakeLists.txt                            |   50 +++++++--
 src/drivers/pipeline/Iterator.cpp             |   91 ++++++++++++++++++
 src/drivers/pipeline/Reader.cpp               |  103 +++++++++++++++++++++
 test/data/pipeline/1.2-with-color.las         |    0 
 test/data/pipeline/pipeline_bad01.xml         |   26 +++++
 test/data/pipeline/pipeline_bad02.xml         |   26 +++++
 test/data/pipeline/pipeline_bad03.xml         |   29 +++++
 test/data/pipeline/pipeline_bad04.xml         |   26 +++++
 test/data/pipeline/pipeline_bad05.xml         |   33 ++++++
 test/data/pipeline/pipeline_bad06.xml         |   33 ++++++
 test/data/pipeline/pipeline_bad07.xml         |   33 ++++++
 test/data/pipeline/pipeline_bad08.xml         |   26 +++++
 test/data/pipeline/pipeline_bad09.xml         |   26 +++++
 test/data/pipeline/pipeline_bad10.xml         |   18 +++
 test/data/pipeline/pipeline_read.xml          |   17 +++
 test/data/pipeline/pipeline_readcomments.xml  |   18 +++
 test/data/pipeline/pipeline_write.xml         |   25 +++++
 test/data/pipeline/pipeline_write2.xml        |   35 +++++++
 test/data/pipeline/pipeline_writecomments.xml |   26 +++++
 test/data/pipeline/utm15.las                  |    0 
 test/data/pipeline_bad01.xml                  |   26 -----
 test/data/pipeline_bad02.xml                  |   26 -----
 test/data/pipeline_bad03.xml                  |   29 -----
 test/data/pipeline_bad04.xml                  |   26 -----
 test/data/pipeline_bad05.xml                  |   33 ------
 test/data/pipeline_bad06.xml                  |   33 ------
 test/data/pipeline_bad07.xml                  |   33 ------
 test/data/pipeline_bad08.xml                  |   26 -----
 test/data/pipeline_bad09.xml                  |   26 -----
 test/data/pipeline_bad10.xml                  |   18 ---
 test/data/pipeline_read.xml                   |   17 ---
 test/data/pipeline_readcomments.xml           |   18 ---
 test/data/pipeline_write.xml                  |   25 -----
 test/data/pipeline_write2.xml                 |   35 -------
 test/data/pipeline_writecomments.xml          |   26 -----
 test/unit/PipelineReaderTest.cpp              |   46 ++++----
 test/unit/PipelineWriterTest.cpp              |    8 +-
 42 files changed, 866 insertions(+), 591 deletions(-)

diffs (truncated from 1903 to 300 lines):

diff -r 0dec1d001f3a -r 730887bf9816 apps/AppSupport.cpp
--- a/apps/AppSupport.cpp	Mon Aug 15 14:02:39 2011 -0700
+++ b/apps/AppSupport.cpp	Mon Aug 15 18:56:50 2011 -0700
@@ -38,54 +38,48 @@
 #include <pdal/Utils.hpp>
 #include <pdal/PipelineManager.hpp>
 #include <pdal/PipelineReader.hpp>
-#include <pdal/drivers/las/Reader.hpp>
-#ifdef PDAL_HAVE_LIBLAS
-#include <pdal/drivers/liblas/Reader.hpp>
-#endif
+#include <pdal/StageFactory.hpp>
 
-AppSupport::FileType AppSupport::inferFileType(const std::string& filename)
+std::string AppSupport::inferReaderDriver(const std::string& filename)
 {
     const std::string ext = boost::filesystem::extension(filename);
 
-    if (pdal::Utils::compare_no_case(ext, ".las")==0) return LAS;
-    if (pdal::Utils::compare_no_case(ext, ".laz")==0) return LAZ;
-    if (pdal::Utils::compare_no_case(ext, ".xml")==0) return XML;
+    // maybe this should live in StageFactory?
+    std::map<std::string, std::string> drivers;
+    drivers[".las"] = "drivers.las.reader";
+    drivers[".laz"] = "drivers.las.reader";
+    drivers[".bin"] = "drivers.terrasolid.reader";
+    drivers[".qi"] = "drivers.qfit.reader";
+    drivers[".xml"] = "drivers.pipeline.reader";
 
-    return UNKNOWN;
+    std::string driver = drivers[ext];
+    if (driver == "")
+    {
+        return "";
+    }
+
+    return driver;
 }
 
 
-pdal::Stage* AppSupport::createReader(FileType type, const std::string& filename, const pdal::Options& extraOptions)
+pdal::Stage* AppSupport::createReader(const std::string& driver, const std::string& filename, const pdal::Options& extraOptions)
 {
     pdal::Stage* reader = NULL;
 
     pdal::Options opts(extraOptions);
     opts.add<std::string>("filename", filename);
 
-    switch (type)
+    if (driver == "drivers.pipeline.reader")
     {
-    case LAS:
-    case LAZ:
-        reader = new pdal::drivers::las::LasReader(opts);
-        reader->initialize();
-        break;
-#ifdef PDAL_HAVE_LIBLAS
-    case LIBLAS_LAS:
-    case LIBLAS_LAZ:
-        reader = new pdal::drivers::liblas::LiblasReader(opts);
-        reader->initialize();
-        break;
-#endif
-    case XML:
-        {
-            pdal::PipelineManager* pipeManager(new pdal::PipelineManager); // BUG: memleak
-            pdal::PipelineReader pipeReader(*pipeManager);
-            pipeReader.readReaderPipeline(filename);
-            reader = pipeManager->getStage();
-        }
-        break;
-    default:
-        return NULL;
+        pdal::PipelineManager* pipeManager(new pdal::PipelineManager); // BUG: memleak
+        pdal::PipelineReader pipeReader(*pipeManager);
+        pipeReader.readReaderPipeline(filename);
+        reader = pipeManager->getStage();
+    }
+    else
+    {
+        pdal::StageFactory factory;
+        reader = factory.createReader(driver, opts);
     }
 
     return reader;
diff -r 0dec1d001f3a -r 730887bf9816 apps/AppSupport.hpp
--- a/apps/AppSupport.hpp	Mon Aug 15 14:02:39 2011 -0700
+++ b/apps/AppSupport.hpp	Mon Aug 15 18:56:50 2011 -0700
@@ -44,21 +44,12 @@
 class AppSupport
 {
 public:
-    enum FileType
-    {
-        LAS,
-        LAZ,
-        LIBLAS_LAS,
-        LIBLAS_LAZ,
-        XML,
-        UNKNOWN
-    };
-
-    static FileType inferFileType(const std::string& filename);
+    // infer the driver to use based on filename extension
+    static std::string inferReaderDriver(const std::string& filename);
 
     // creates a Reader using the given driver type
     // caller takes ownership of the returned pointer... unless it's of type XML :-(
-    static pdal::Stage* createReader(FileType type, const std::string& filename, const pdal::Options& options);
+    static pdal::Stage* createReader(const std::string& driver, const std::string& filename, const pdal::Options& options);
 
     AppSupport& operator=(const AppSupport&); // not implemented
     AppSupport(const AppSupport&); // not implemented
diff -r 0dec1d001f3a -r 730887bf9816 apps/pcinfo.cpp
--- a/apps/pcinfo.cpp	Mon Aug 15 14:02:39 2011 -0700
+++ b/apps/pcinfo.cpp	Mon Aug 15 18:56:50 2011 -0700
@@ -50,6 +50,7 @@
     bool validateOptions();
 
     std::string m_inputFile;
+    boost::uint64_t m_pointNumber;
 };
 
 
@@ -84,6 +85,15 @@
 
     addOptionSet(file_options);
 
+    po::options_description* processing_options = new po::options_description("processing options");
+
+    processing_options->add_options()
+        ("point,p", po::value<boost::uint64_t>(&m_pointNumber), "point to dump")
+        ("points", "dump stats on all points (read entire dataset)")
+        ;
+
+    addOptionSet(processing_options);
+
     addPositionalOption("input", 1);
 
     return;
@@ -98,9 +108,9 @@
         return 1;
     }
 
-    AppSupport::FileType type = AppSupport::inferFileType(m_inputFile);
+    std::string driver = AppSupport::inferReaderDriver(m_inputFile);
 
-    if (type == AppSupport::UNKNOWN)
+    if (driver == "")
     {
         runtimeError("Cannot determine file type of " + m_inputFile);
         return 1;
@@ -108,21 +118,13 @@
 
     if (hasOption("liblas"))
     {
-        switch (type)
+        if (driver == "drivers.las.reader")
         {
-        case AppSupport::LAS:
-            type = AppSupport::LIBLAS_LAS;
-            break;
-        case AppSupport::LAZ:
-            type = AppSupport::LIBLAS_LAZ;
-            break;
-        default:
-            // switch has no effect
-            break;
+            driver = "drivers.liblas.reader";
         }
     }
 
-    pdal::Stage* reader = AppSupport::createReader(type, m_inputFile, pdal::Options::none());
+    pdal::Stage* reader = AppSupport::createReader(driver, m_inputFile, pdal::Options::none());
 
     const boost::uint64_t numPoints = reader->getNumPoints();
     const pdal::SpatialReference& srs = reader->getSpatialReference();
@@ -130,7 +132,7 @@
     std::cout << numPoints << " points\n";
     std::cout << "WKT: " << srs.getWKT() << "\n";
 
-    if (type != AppSupport::XML)
+    if (driver != "drivers.pipeline.reader")
     {
         delete reader;
     }
@@ -147,17 +149,6 @@
 
 #if 0
 
-#include <liblas/liblas.hpp>
-#include "laskernel.hpp"
-
-#include <boost/cstdint.hpp>
-#include <boost/foreach.hpp>
-
-#include <locale>
-
-
-using namespace liblas;
-using namespace std;
 
 
 liblas::Summary check_points(   liblas::Reader& reader,
@@ -201,20 +192,7 @@
     
 }
 
-void OutputHelp( std::ostream & oss, po::options_description const& options)
-{
-    oss << "--------------------------------------------------------------------\n";
-    oss << "    lasinfo (" << GetFullVersion() << ")\n";
-    oss << "--------------------------------------------------------------------\n";
 
-    oss << options;
-
-    oss <<"\nFor more information, see the full documentation for lasinfo at:\n";
-    
-    oss << " http://liblas.org/utilities/lasinfo.html\n";
-    oss << "----------------------------------------------------------\n";
-
-}
 
 void PrintVLRs(std::ostream& os, liblas::Header const& header)
 {
@@ -249,26 +227,9 @@
     bool use_locale = false;
     boost::uint32_t point = 0;
     
-    std::vector<liblas::FilterPtr> filters;
-    std::vector<liblas::TransformPtr> transforms;
-    
-    liblas::Header header;
 
-    try {
-
-        po::options_description file_options("lasinfo 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-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")
@@ -280,60 +241,17 @@
 // --xml
 // --json
 // --restructured text output
-        ;
 
-        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("point")) 
         {
             show_point = true;
         }
 
-        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..." << std::endl;
-                return 1;
-            }
-            liblas::ReaderFactory f;
-            liblas::Reader reader = f.CreateWithStream(ifs);
-            header = reader.GetHeader();
-        } else {
-            std::cerr << "Input LAS file not specified!\n";
-            OutputHelp(std::cout, options);
-            return 1;
-        }
 
 
-        filters = GetFilters(vm, verbose);
 


More information about the Liblas-commits mailing list