[Liblas-commits] hg-main-tree: pc2pc work
liblas-commits at liblas.org
liblas-commits at liblas.org
Thu Aug 18 00:45:10 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/da24fd92e641
changeset: 1128:da24fd92e641
user: Michael P. Gerlek <mpg at flaxen.com>
date: Wed Aug 17 21:44:53 2011 -0700
description:
pc2pc work
diffstat:
apps/AppSupport.cpp | 75 +++++++++++++++++++++-------------------------------
apps/AppSupport.hpp | 17 ++++-------
apps/pc2pc.cpp | 12 +++++--
3 files changed, 45 insertions(+), 59 deletions(-)
diffs (198 lines):
diff -r 30d1b1369259 -r da24fd92e641 apps/AppSupport.cpp
--- a/apps/AppSupport.cpp Wed Aug 17 14:37:00 2011 -0700
+++ b/apps/AppSupport.cpp Wed Aug 17 21:44:53 2011 -0700
@@ -44,7 +44,7 @@
#include <pdal/StageFactory.hpp>
-std::string AppSupport::inferReaderDriver(const std::string& filename)
+std::string AppSupport::inferReaderDriver(const std::string& filename, pdal::Options& options)
{
std::string ext = boost::filesystem::extension(filename);
if (ext == "") return "";
@@ -53,6 +53,8 @@
boost::to_lower(ext);
+ options.add<std::string>("filename", filename);
+
// maybe this should live in StageFactory?
std::map<std::string, std::string> drivers;
drivers["las"] = "drivers.las.reader";
@@ -66,7 +68,7 @@
}
-std::string AppSupport::inferWriterDriver(const std::string& filename)
+std::string AppSupport::inferWriterDriver(const std::string& filename, pdal::Options& options)
{
std::string ext = boost::filesystem::extension(filename);
if (ext == "") return "";
@@ -75,6 +77,13 @@
boost::to_lower(ext);
+ if (ext == "laz")
+ {
+ options.add("compress", true);
+ }
+
+ options.add<std::string>("filename", filename);
+
// maybe this should live in StageFactory?
std::map<std::string, std::string> drivers;
drivers["las"] = "drivers.las.writer";
@@ -85,34 +94,6 @@
}
-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);
-
- pdal::StageFactory factory;
- reader = factory.createReader(driver, opts);
-
- return reader;
-}
-
-
-pdal::Writer* AppSupport::createWriter(const std::string& driver, const std::string& filename, pdal::Stage& stage, const pdal::Options& extraOptions)
-{
- pdal::Writer* writer = NULL;
-
- pdal::Options opts(extraOptions);
- opts.add<std::string>("filename", filename);
-
- pdal::StageFactory factory;
- writer = factory.createWriter(driver, stage, opts);
-
- return writer;
-}
-
-
pdal::Stage* AppSupport::makeReader(const std::string& inputFile, const Application& app)
{
if (!pdal::FileUtils::fileExists(inputFile))
@@ -120,7 +101,11 @@
throw app_runtime_error("file not found: " + inputFile);
}
- std::string driver = AppSupport::inferReaderDriver(inputFile);
+ pdal::Options options;
+ options.add<bool>("debug", app.isDebug());
+ options.add<boost::uint8_t>("verbose", app.getVerboseLevel());
+
+ std::string driver = AppSupport::inferReaderDriver(inputFile, options);
if (driver == "")
{
throw app_runtime_error("Cannot determine file type of " + inputFile);
@@ -131,19 +116,20 @@
driver = "drivers.liblas.reader";
}
+ pdal::StageFactory factory;
+ pdal::Stage* stage = factory.createReader(driver, options);
+
+ return stage;
+}
+
+
+pdal::Writer* AppSupport::makeWriter(const std::string& outputFile, pdal::Stage& stage, const Application& app)
+{
pdal::Options options;
options.add<bool>("debug", app.isDebug());
options.add<boost::uint8_t>("verbose", app.getVerboseLevel());
- pdal::Stage* stage = AppSupport::createReader(driver, inputFile, options);
-
- return stage;
-}
-
-
-pdal::Writer* AppSupport::makeWriter(const std::string& outputFile, pdal::Stage& stage, const Application& app)
-{
- std::string driver = AppSupport::inferWriterDriver(outputFile);
+ std::string driver = AppSupport::inferWriterDriver(outputFile, options);
if (driver == "")
{
throw app_runtime_error("Cannot determine file type of " + outputFile);
@@ -154,11 +140,10 @@
driver = "drivers.liblas.writer";
}
- pdal::Options options;
- options.add<bool>("debug", app.isDebug());
- options.add<boost::uint8_t>("verbose", app.getVerboseLevel());
-
- pdal::Writer* writer = AppSupport::createWriter(driver, outputFile, stage, options);
+ options.add<bool>("compression", app.hasOption("compress"));
+
+ pdal::StageFactory factory;
+ pdal::Writer* writer = factory.createWriter(driver, stage, options);
return writer;
}
diff -r 30d1b1369259 -r da24fd92e641 apps/AppSupport.hpp
--- a/apps/AppSupport.hpp Wed Aug 17 14:37:00 2011 -0700
+++ b/apps/AppSupport.hpp Wed Aug 17 21:44:53 2011 -0700
@@ -57,19 +57,16 @@
private:
// infer the driver to use based on filename extension
// returns "" if no driver found
- static std::string inferReaderDriver(const std::string& filename);
+ //
+ // this may also add on an option to pass to the driver, such as the filename
+ static std::string inferReaderDriver(const std::string& filename, pdal::Options& options);
// infer the driver to use based on filename extension
// returns "" if no driver found
- static std::string inferWriterDriver(const std::string& filename);
-
- // creates a Reader using the given driver type
- // caller does NOT take ownership of the returned pointer
- static pdal::Stage* createReader(const std::string& driver, const std::string& filename, const pdal::Options& options);
-
- // creates a Writer using the given driver type
- // caller does NOT take ownership of the returned pointer
- static pdal::Writer* createWriter(const std::string& driver, const std::string& filename, pdal::Stage& stage, const pdal::Options& options);
+ //
+ // this may also add on an option to pass to the driver, such as the filename
+ // (or something inferred from the extension, such as .laz means we need to use compress=true)
+ static std::string inferWriterDriver(const std::string& filename, pdal::Options& options);
AppSupport& operator=(const AppSupport&); // not implemented
AppSupport(const AppSupport&); // not implemented
diff -r 30d1b1369259 -r da24fd92e641 apps/pc2pc.cpp
--- a/apps/pc2pc.cpp Wed Aug 17 14:37:00 2011 -0700
+++ b/apps/pc2pc.cpp Wed Aug 17 21:44:53 2011 -0700
@@ -114,8 +114,8 @@
("input,i", po::value<std::string>(&m_inputFile), "input file name")
("output,o", po::value<std::string>(&m_outputFile), "output file name")
("liblas", "use libLAS driver (not PDAL native driver)")
-// ("a_srs", po::value<std::string>(&m_srs)->default_value(""), "Assign output coordinate system")
-// ("compress", po::value<bool>(&m_bCompress)->zero_tokens()->implicit_value(true),"Compress output data if available")
+ ("a_srs", po::value<std::string>(&m_srs)->default_value(""), "Assign output coordinate system")
+ ("compress", "Compress output data (if supported by output format)")
;
addOptionSet(file_options);
@@ -126,9 +126,13 @@
{
pdal::Stage* stage = AppSupport::makeReader(m_inputFile, *this);
- //BUG: handle laz writer.setCompressed(false);
+ if (hasOption("a_srs"))
+ {
+ // ???
+ }
- //writer.setPointFormat( reader.getPointFormatNumber() );
+ // BUG: I don't know how we could do this...
+ // writer.setPointFormat( reader.getPointFormat() );
pdal::Writer* writer = AppSupport::makeWriter(m_outputFile, *stage, *this);
More information about the Liblas-commits
mailing list