[Liblas-commits] hg-main-tree: turn on Options ctor

liblas-commits at liblas.org liblas-commits at liblas.org
Fri Jul 15 02:35:35 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/159f413329f4
changeset: 863:159f413329f4
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Jul 14 23:33:29 2011 -0700
description:
turn on Options ctor
Subject: hg-main-tree: missing \#incl

details:   http://hg.libpc.orghg-main-tree/rev/921e43033618
changeset: 864:921e43033618
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Jul 14 23:34:23 2011 -0700
description:
missing \#incl
Subject: hg-main-tree: typo

details:   http://hg.libpc.orghg-main-tree/rev/4270c2efe0cf
changeset: 865:4270c2efe0cf
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Jul 14 23:34:40 2011 -0700
description:
typo
Subject: hg-main-tree: syn with new ctor

details:   http://hg.libpc.orghg-main-tree/rev/73e23590f44f
changeset: 866:73e23590f44f
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Jul 14 23:34:58 2011 -0700
description:
syn with new ctor
Subject: hg-main-tree: more tests

details:   http://hg.libpc.orghg-main-tree/rev/8df5c02ac502
changeset: 867:8df5c02ac502
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Jul 14 23:35:27 2011 -0700
description:
more tests

diffstat:

 include/pdal/Options.hpp              |   1 +
 include/pdal/filters/MosaicFilter.hpp |   1 -
 src/StageFactory.cpp                  |   2 +-
 src/filters/MosaicFilter.cpp          |   7 --
 test/unit/MosaicFilterTest.cpp        |   2 +-
 test/unit/StageFactoryTest.cpp        |  88 +++++++++++++++++++++++++++++++++++
 6 files changed, 91 insertions(+), 10 deletions(-)

diffs (180 lines):

diff -r cc83cbdc225c -r 8df5c02ac502 include/pdal/Options.hpp
--- a/include/pdal/Options.hpp	Thu Jul 14 13:11:40 2011 -0700
+++ b/include/pdal/Options.hpp	Thu Jul 14 23:35:27 2011 -0700
@@ -36,6 +36,7 @@
 #define INCLUDED_OPTIONS_HPP
 
 #include <pdal/pdal.hpp>
+#include <pdal/exceptions.hpp>
 #include <pdal/Bounds.hpp>
 #include <boost/property_tree/ptree.hpp>
 
diff -r cc83cbdc225c -r 8df5c02ac502 include/pdal/filters/MosaicFilter.hpp
--- a/include/pdal/filters/MosaicFilter.hpp	Thu Jul 14 13:11:40 2011 -0700
+++ b/include/pdal/filters/MosaicFilter.hpp	Thu Jul 14 23:35:27 2011 -0700
@@ -54,7 +54,6 @@
     // entries may not be null
     // vector.size() must be > 0
     MosaicFilter(const std::vector<const Stage*>& prevStages, const Options& options);
-    MosaicFilter(const std::vector<const Stage*>& prevStages);
     
     const std::string& getDescription() const;
     const std::string& getName() const;
diff -r cc83cbdc225c -r 8df5c02ac502 src/StageFactory.cpp
--- a/src/StageFactory.cpp	Thu Jul 14 13:11:40 2011 -0700
+++ b/src/StageFactory.cpp	Thu Jul 14 23:35:27 2011 -0700
@@ -223,7 +223,7 @@
     registerFilter("filters.reprojection", create_filters_reprojectionfilter);
     registerFilter("filters.scaling", create_filters_scalingfilter);
 
-    registerMultiFilter("filters.mosaicfilter", create_filters_mosaicfilter);
+    registerMultiFilter("filters.mosaic", create_filters_mosaicfilter);
 
     return;
 }
diff -r cc83cbdc225c -r 8df5c02ac502 src/filters/MosaicFilter.cpp
--- a/src/filters/MosaicFilter.cpp	Thu Jul 14 13:11:40 2011 -0700
+++ b/src/filters/MosaicFilter.cpp	Thu Jul 14 23:35:27 2011 -0700
@@ -44,13 +44,6 @@
 MosaicFilter::MosaicFilter(const std::vector<const Stage*>& prevStages, const Options& options)
     : pdal::MultiFilter(prevStages, options)
 {
-     throw not_yet_implemented("mosaic filter options support"); 
-}
-
-
-MosaicFilter::MosaicFilter(const std::vector<const Stage*>& prevStages)
-    : MultiFilter(prevStages, Options::none())
-{
     if (prevStages.size() == 0)
     {
         throw pdal_error("empty stage list passed to mosaic filter");
diff -r cc83cbdc225c -r 8df5c02ac502 test/unit/MosaicFilterTest.cpp
--- a/test/unit/MosaicFilterTest.cpp	Thu Jul 14 13:11:40 2011 -0700
+++ b/test/unit/MosaicFilterTest.cpp	Thu Jul 14 23:35:27 2011 -0700
@@ -61,7 +61,7 @@
     vec.push_back(&reader2);
     vec.push_back(&reader3);
 
-    pdal::filters::MosaicFilter mosaic(vec);
+    pdal::filters::MosaicFilter mosaic(vec, Options::none());
     BOOST_CHECK(mosaic.getDescription() == "Mosaic Filter");
 
     const Schema& schema = mosaic.getSchema();
diff -r cc83cbdc225c -r 8df5c02ac502 test/unit/StageFactoryTest.cpp
--- a/test/unit/StageFactoryTest.cpp	Thu Jul 14 13:11:40 2011 -0700
+++ b/test/unit/StageFactoryTest.cpp	Thu Jul 14 23:35:27 2011 -0700
@@ -41,6 +41,10 @@
 #include <pdal/Filter.hpp>
 #include <pdal/Writer.hpp>
 #include <pdal/Options.hpp>
+#include <pdal/drivers/las/Reader.hpp>
+#include <pdal/drivers/las/Writer.hpp>
+#include <pdal/filters/CropFilter.hpp>
+#include <pdal/filters/MosaicFilter.hpp>
 
 using namespace pdal;
 
@@ -53,6 +57,7 @@
 
     boost::shared_ptr<Reader> ptrR;
     boost::shared_ptr<Filter> ptrF;
+    boost::shared_ptr<MultiFilter> ptrM;
     boost::shared_ptr<Writer> ptrW;
     
     const Options optsR("filename", Support::datapath("1.2-with-color.las"), "file to read from");
@@ -63,6 +68,12 @@
     ptrF = factory.createFilter("filters.crop", *ptrR, optsF);
     BOOST_CHECK(ptrF->getName() == "filters.crop");
 
+    const Options optsM;
+    std::vector<const Stage*> stages;
+    stages.push_back(ptrR.get());
+    ptrM = factory.createMultiFilter("filters.mosaic", stages, optsM);
+    BOOST_CHECK(ptrM->getName() == "filters.mosaic");
+
     const Options optsW("filename", "temp.las", "file to write to");
     ptrW = factory.createWriter("drivers.las.writer", *ptrF, optsW);
     BOOST_CHECK(ptrW->getName() == "drivers.las.writer");
@@ -71,4 +82,81 @@
 }
 
 
+static int s_demoflag = 0;
+Reader* demoReaderCreator(const Options& options)
+{
+    s_demoflag = options.getValue<int>("flag");
+
+    // this is where you'd do something like:
+    //     return new MyCustomXyzReader(options);
+
+    const Options optsR("filename", Support::datapath("1.2-with-color.las"), "file to read from");
+    return new pdal::drivers::las::LasReader(optsR);
+}
+
+Filter* demoFilterCreator(const Stage& prev, const Options& options)
+{
+    s_demoflag = options.getValue<int>("flag");
+
+    const Options optsF("bounds", Bounds<double>(0,0,0,1,1,1), "crop bounds");
+    return new pdal::filters::CropFilter(prev, optsF);
+}
+
+MultiFilter* demoMultiFilterCreator(const std::vector<const Stage*>& prevs, const Options& options)
+{
+    s_demoflag = options.getValue<int>("flag");
+
+    const Options optsM;
+    return new pdal::filters::MosaicFilter(prevs, optsM);
+}
+
+Writer* demoWriterCreator(const Stage& prev, const Options& options)
+{
+    s_demoflag = options.getValue<int>("flag");
+
+    const Options optsW("filename", "temp.las", "file to write to");
+    return new pdal::drivers::las::LasWriter(prev, optsW);
+}
+
+
+
+BOOST_AUTO_TEST_CASE(test2)
+{
+    StageFactory factory;
+
+    factory.registerReader("demoR", demoReaderCreator);
+    factory.registerFilter("demoF", demoFilterCreator);
+    factory.registerMultiFilter("demoM", demoMultiFilterCreator);
+    factory.registerWriter("demoW", demoWriterCreator);
+
+    s_demoflag = 0;
+    Options optsR("flag",11,"my flag");
+    boost::shared_ptr<Reader> reader = factory.createReader("demoR", optsR);
+    BOOST_CHECK(reader->getName() == "drivers.las.reader");
+    BOOST_CHECK(s_demoflag == 11);
+
+    s_demoflag = 0;
+    Options optsF("flag",22,"my flag");
+    boost::shared_ptr<Filter> filter = factory.createFilter("demoF", *reader, optsF);
+    BOOST_CHECK(filter->getName() == "filters.crop");
+    BOOST_CHECK(s_demoflag == 22);
+
+    s_demoflag = 0;
+    Options optsM("flag",33,"my flag");
+    std::vector<const Stage*> stages;
+    stages.push_back(reader.get());
+    boost::shared_ptr<MultiFilter> multifilter = factory.createMultiFilter("demoM", stages, optsM);
+    BOOST_CHECK(multifilter->getName() == "filters.mosaic");
+    BOOST_CHECK(s_demoflag == 33);
+
+    s_demoflag = 0;
+    Options optsW("flag",44,"my flag");
+    boost::shared_ptr<Writer> writer = factory.createWriter("demoW", *reader, optsW);
+    BOOST_CHECK(writer->getName() == "drivers.las.writer");
+    BOOST_CHECK(s_demoflag == 44);
+
+    return;
+}
+
+
 BOOST_AUTO_TEST_SUITE_END()


More information about the Liblas-commits mailing list