[Liblas-commits] hg-main-tree: added comment
liblas-commits at liblas.org
liblas-commits at liblas.org
Thu Aug 18 16:33:40 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/4175d14b5322
changeset: 1129:4175d14b5322
user: Michael P. Gerlek <mpg at flaxen.com>
date: Thu Aug 18 10:47:38 2011 -0700
description:
added comment
Subject: hg-main-tree: options work
details: http://hg.libpc.orghg-main-tree/rev/a88fde137f1a
changeset: 1130:a88fde137f1a
user: Michael P. Gerlek <mpg at flaxen.com>
date: Thu Aug 18 10:48:26 2011 -0700
description:
options work
Subject: hg-main-tree: call init() first
details: http://hg.libpc.orghg-main-tree/rev/0fa20f73ae43
changeset: 1131:0fa20f73ae43
user: Michael P. Gerlek <mpg at flaxen.com>
date: Thu Aug 18 10:48:40 2011 -0700
description:
call init() first
Subject: hg-main-tree: app work
details: http://hg.libpc.orghg-main-tree/rev/ce1abe2de36a
changeset: 1132:ce1abe2de36a
user: Michael P. Gerlek <mpg at flaxen.com>
date: Thu Aug 18 10:49:02 2011 -0700
description:
app work
Subject: hg-main-tree: add an empty() checker
details: http://hg.libpc.orghg-main-tree/rev/fe32a969063d
changeset: 1133:fe32a969063d
user: Michael P. Gerlek <mpg at flaxen.com>
date: Thu Aug 18 11:50:48 2011 -0700
description:
add an empty() checker
Subject: hg-main-tree: handle eof correctly
details: http://hg.libpc.orghg-main-tree/rev/1bcfd4a7e368
changeset: 1134:1bcfd4a7e368
user: Michael P. Gerlek <mpg at flaxen.com>
date: Thu Aug 18 12:56:42 2011 -0700
description:
handle eof correctly
Subject: hg-main-tree: add case showing bug
details: http://hg.libpc.orghg-main-tree/rev/6f7e37dd5a27
changeset: 1135:6f7e37dd5a27
user: Michael P. Gerlek <mpg at flaxen.com>
date: Thu Aug 18 12:57:07 2011 -0700
description:
add case showing bug
Subject: hg-main-tree: add test for empty()
details: http://hg.libpc.orghg-main-tree/rev/658e7af0c887
changeset: 1136:658e7af0c887
user: Michael P. Gerlek <mpg at flaxen.com>
date: Thu Aug 18 12:57:26 2011 -0700
description:
add test for empty()
Subject: hg-main-tree: apps work, incl. hack for put/add Options issue and more tests
details: http://hg.libpc.orghg-main-tree/rev/046b18103cee
changeset: 1137:046b18103cee
user: Michael P. Gerlek <mpg at flaxen.com>
date: Thu Aug 18 12:58:11 2011 -0700
description:
apps work, incl. hack for put/add Options issue and more tests
Subject: hg-main-tree: comment
details: http://hg.libpc.orghg-main-tree/rev/2ab795dd711c
changeset: 1138:2ab795dd711c
user: Michael P. Gerlek <mpg at flaxen.com>
date: Thu Aug 18 13:07:51 2011 -0700
description:
comment
Subject: hg-main-tree: pcinfo tests
details: http://hg.libpc.orghg-main-tree/rev/657d1b19e8a7
changeset: 1139:657d1b19e8a7
user: Michael P. Gerlek <mpg at flaxen.com>
date: Thu Aug 18 13:07:59 2011 -0700
description:
pcinfo tests
Subject: hg-main-tree: cleanup temp files
details: http://hg.libpc.orghg-main-tree/rev/9b4238f42d8f
changeset: 1140:9b4238f42d8f
user: Michael P. Gerlek <mpg at flaxen.com>
date: Thu Aug 18 13:09:11 2011 -0700
description:
cleanup temp files
Subject: hg-main-tree: pcinfo testing
details: http://hg.libpc.orghg-main-tree/rev/f449609b8009
changeset: 1141:f449609b8009
user: Michael P. Gerlek <mpg at flaxen.com>
date: Thu Aug 18 13:33:19 2011 -0700
description:
pcinfo testing
diffstat:
apps/AppSupport.cpp | 36 +++--
apps/AppSupport.hpp | 8 +-
apps/Application.cpp | 39 +++---
apps/Application.hpp | 16 +-
apps/pc2pc.cpp | 60 +++++++---
apps/pcinfo.cpp | 164 ++++++++++++++++++----------
apps/pcpipeline.cpp | 44 +++----
include/pdal/SpatialReference.hpp | 4 +
include/pdal/Writer.hpp | 4 +
include/pdal/drivers/las/Writer.hpp | 11 +-
include/pdal/drivers/liblas/Writer.hpp | 9 +
include/pdal/drivers/qfit/Reader.hpp | 6 +
include/pdal/drivers/terrasolid/Reader.hpp | 6 +
src/SpatialReference.cpp | 6 +
src/Writer.cpp | 12 ++
src/drivers/las/Writer.cpp | 19 +--
src/drivers/liblas/Iterator.cpp | 5 +-
src/drivers/liblas/Writer.cpp | 7 +
test/data/apps/simple.las | 0
test/data/apps/simple.laz | 0
test/unit/LasWriterTest.cpp | 5 +-
test/unit/OptionsTest.cpp | 14 ++
test/unit/SpatialReferenceTest.cpp | 2 +
test/unit/pc2pcTest.cpp | 97 ++++++++++++++++-
test/unit/pcinfoTest.cpp | 71 ++++++++++++
25 files changed, 472 insertions(+), 173 deletions(-)
diffs (truncated from 1282 to 300 lines):
diff -r da24fd92e641 -r f449609b8009 apps/AppSupport.cpp
--- a/apps/AppSupport.cpp Wed Aug 17 21:44:53 2011 -0700
+++ b/apps/AppSupport.cpp Thu Aug 18 13:33:19 2011 -0700
@@ -79,7 +79,7 @@
if (ext == "laz")
{
- options.add("compress", true);
+ options.add("compression_hack2", true);
}
options.add<std::string>("filename", filename);
@@ -94,40 +94,40 @@
}
-pdal::Stage* AppSupport::makeReader(const std::string& inputFile, const Application& app)
+pdal::Stage& AppSupport::makeReader(pdal::Options& options)
{
+ const std::string inputFile = options.getValueOrThrow<std::string>("filename");
+
if (!pdal::FileUtils::fileExists(inputFile))
{
throw app_runtime_error("file not found: " + 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);
}
- if (app.hasOption("liblas") && driver == "drivers.las.reader")
+ if (options.getValueOrDefault<bool>("liblas", false) && driver == "drivers.las.reader")
{
driver = "drivers.liblas.reader";
}
pdal::StageFactory factory;
pdal::Stage* stage = factory.createReader(driver, options);
+ if (!stage)
+ {
+ throw app_runtime_error("reader creation failed");
+ }
- return stage;
+ return *stage;
}
-pdal::Writer* AppSupport::makeWriter(const std::string& outputFile, pdal::Stage& stage, const Application& app)
+pdal::Writer& AppSupport::makeWriter(pdal::Options& options, pdal::Stage& stage)
{
- pdal::Options options;
- options.add<bool>("debug", app.isDebug());
- options.add<boost::uint8_t>("verbose", app.getVerboseLevel());
+ const std::string outputFile = options.getValueOrThrow<std::string>("filename");
std::string driver = AppSupport::inferWriterDriver(outputFile, options);
if (driver == "")
@@ -135,15 +135,19 @@
throw app_runtime_error("Cannot determine file type of " + outputFile);
}
- if (app.hasOption("liblas") && driver == "drivers.las.writer")
+ if (options.getValueOrDefault<bool>("liblas", false) && driver == "drivers.las.writer")
{
driver = "drivers.liblas.writer";
}
+
+ options.add<bool>("compression", options.getValueOrDefault("compression_hack1", false) || options.getValueOrDefault("compression_hack2", false));
- options.add<bool>("compression", app.hasOption("compress"));
-
pdal::StageFactory factory;
pdal::Writer* writer = factory.createWriter(driver, stage, options);
+ if (!writer)
+ {
+ throw app_runtime_error("writer creation failed");
+ }
- return writer;
+ return *writer;
}
diff -r da24fd92e641 -r f449609b8009 apps/AppSupport.hpp
--- a/apps/AppSupport.hpp Wed Aug 17 21:44:53 2011 -0700
+++ b/apps/AppSupport.hpp Thu Aug 18 13:33:19 2011 -0700
@@ -48,11 +48,11 @@
class AppSupport
{
public:
- // makes a reader/stage, from just the filename and some options
- static pdal::Stage* AppSupport::makeReader(const std::string& inputFile, const Application& app);
+ // makes a reader/stage, from just the filename and some other options
+ static pdal::Stage& AppSupport::makeReader(pdal::Options& options);
- // makes a writer, from just the filename and some options (and the input stage)
- static pdal::Writer* AppSupport::makeWriter(const std::string& outputFile, pdal::Stage& stage, const Application& app);
+ // makes a writer, from just the filename and some other options (and the input stage)
+ static pdal::Writer& AppSupport::makeWriter(pdal::Options& options, pdal::Stage& stage);
private:
// infer the driver to use based on filename extension
diff -r da24fd92e641 -r f449609b8009 apps/Application.cpp
--- a/apps/Application.cpp Wed Aug 17 21:44:53 2011 -0700
+++ b/apps/Application.cpp Thu Aug 18 13:33:19 2011 -0700
@@ -47,6 +47,9 @@
Application::Application(int argc, char* argv[], const std::string& appName)
: m_isDebug(false)
, m_verboseLevel(0)
+ , m_showHelp(false)
+ , m_showVersion(false)
+ , m_showTime(false)
, m_argc(argc)
, m_argv(argv)
, m_appName(appName)
@@ -89,22 +92,22 @@
int Application::innerRun()
{
// add -h, -v, etc
- addBasicOptionSet();
+ addBasicSwitchSet();
// add the options for the derived application
- addOptions();
+ addSwitches();
// parse the command line
- parseOptions();
+ parseSwitches();
// handle the well-known options
- if (hasOption("version"))
+ if (m_showVersion)
{
outputVersion();
return 0;
}
- if (hasOption("help"))
+ if (m_showHelp)
{
outputHelp();
return 0;
@@ -113,7 +116,7 @@
try
{
// do any user-level sanity checking
- validateOptions();
+ validateSwitches();
}
catch (app_usage_error e)
{
@@ -127,7 +130,7 @@
int status = execute();
- if (status == 0 && hasOption("timer"))
+ if (status == 0 && m_showTime)
{
const double t = timer.elapsed();
std::cout << "Elapsed time: " << t << " seconds" << std::endl;
@@ -144,12 +147,6 @@
}
-bool Application::hasOption(const std::string& name) const
-{
- return m_variablesMap.count(name) > 0;
-}
-
-
bool Application::isDebug() const
{
return m_isDebug;
@@ -166,14 +163,14 @@
}
-void Application::addOptionSet(po::options_description* options)
+void Application::addSwitchSet(po::options_description* options)
{
if (!options) return;
m_options.push_back(options);
}
-void Application::addPositionalOption(const char* name, int max_count)
+void Application::addPositionalSwitch(const char* name, int max_count)
{
m_positionalOptions.add(name, max_count);
}
@@ -210,25 +207,25 @@
}
-void Application::addBasicOptionSet()
+void Application::addBasicSwitchSet()
{
po::options_description* basic_options = new po::options_description("basic options");
basic_options->add_options()
- ("help,h", "produce help message")
+ ("help,h", po::value<bool>(&m_showHelp)->zero_tokens(), "produce help message")
("debug,d", po::value<bool>(&m_isDebug)->zero_tokens(), "Enable debug mode")
("verbose,v", po::value<boost::uint32_t>(&m_verboseLevel)->default_value(0), "Set verbose message level")
- ("version", "Show version info")
- ("timer", "Show execution time")
+ ("version", po::value<bool>(&m_showVersion)->zero_tokens(), "Show version info")
+ ("timer", po::value<bool>(&m_showTime)->zero_tokens(), "Show execution time")
;
- addOptionSet(basic_options);
+ addSwitchSet(basic_options);
return;
}
-void Application::parseOptions()
+void Application::parseSwitches()
{
po::options_description options;
diff -r da24fd92e641 -r f449609b8009 apps/Application.hpp
--- a/apps/Application.hpp Wed Aug 17 21:44:53 2011 -0700
+++ b/apps/Application.hpp Thu Aug 18 13:33:19 2011 -0700
@@ -82,7 +82,6 @@
bool isDebug() const;
boost::uint8_t getVerboseLevel() const;
- bool hasOption(const std::string& name) const;
void printError(const std::string&) const;
protected:
@@ -90,28 +89,31 @@
Application(int argc, char* argv[], const std::string& appName);
// implement this, with calls to addOptionSet()
- virtual void addOptions() {}
+ virtual void addSwitches() {}
// implement this, to do sanity checking of cmd line
// will throw if the user gave us bad options
- virtual void validateOptions() {}
+ virtual void validateSwitches() {}
// implement this, to do your actual work
// it will be wrapped in a global catch try/block for you
virtual int execute() = 0;
- void addOptionSet(boost::program_options::options_description* options);
- void addPositionalOption(const char* name, int max_count);
+ void addSwitchSet(boost::program_options::options_description* options);
+ void addPositionalSwitch(const char* name, int max_count);
private:
int innerRun();
- void parseOptions();
+ void parseSwitches();
void outputHelp();
void outputVersion();
- void addBasicOptionSet();
+ void addBasicSwitchSet();
bool m_isDebug;
boost::uint32_t m_verboseLevel;
+ bool m_showHelp;
+ bool m_showVersion;
+ bool m_showTime;
const int m_argc;
char** m_argv;
const std::string m_appName;
diff -r da24fd92e641 -r f449609b8009 apps/pc2pc.cpp
--- a/apps/pc2pc.cpp Wed Aug 17 21:44:53 2011 -0700
+++ b/apps/pc2pc.cpp Thu Aug 18 13:33:19 2011 -0700
@@ -70,11 +70,12 @@
int execute();
private:
- void addOptions();
- void validateOptions();
+ void addSwitches();
+ void validateSwitches();
std::string m_inputFile;
std::string m_outputFile;
+ bool m_useLiblas;
std::string m_srs;
bool m_bCompress;
@@ -83,19 +84,24 @@
Pc2Pc::Pc2Pc(int argc, char* argv[])
: Application(argc, argv, "pc2pc")
+ , m_inputFile("")
More information about the Liblas-commits
mailing list