[Liblas-commits] hg: 2 new changesets
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Aug 11 12:23:13 EDT 2010
changeset 44971e6e7e13 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=44971e6e7e13
summary: update lasblock to user boost::program_options, update chipper to use liblas::Bounds<double> instead of individual methods
changeset 244af56577e7 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=244af56577e7
summary: copy/paste typo
diffstat:
apps/CMakeLists.txt | 2 +-
apps/chipper.cpp | 26 ++++--
apps/chipper.hpp | 27 +++---
apps/las2las2.cpp | 2 +-
apps/lasblock.cpp | 173 +++++++++++++++++++++++++-------------------
doc/utilities/lasblock.txt | 22 +++++-
6 files changed, 154 insertions(+), 98 deletions(-)
diffs (truncated from 370 to 300 lines):
diff -r 92878748f048 -r 244af56577e7 apps/CMakeLists.txt
--- a/apps/CMakeLists.txt Tue Aug 10 15:53:44 2010 -0500
+++ b/apps/CMakeLists.txt Wed Aug 11 11:23:05 2010 -0500
@@ -117,7 +117,7 @@
if(LASBLOCK)
set(LASBLOCK_SRC lasblock.cpp chipper.cpp chipper.hpp)
add_executable(${LASBLOCK} ${LASBLOCK_SRC})
- target_link_libraries(${LASBLOCK} ${APPS_CPP_DEPENDENCIES})
+ target_link_libraries(${LASBLOCK} ${APPS_CPP_DEPENDENCIES} ${Boost_LIBRARIES})
endif()
# Build las2ogr
diff -r 92878748f048 -r 244af56577e7 apps/chipper.cpp
--- a/apps/chipper.cpp Tue Aug 10 15:53:44 2010 -0500
+++ b/apps/chipper.cpp Wed Aug 11 11:23:05 2010 -0500
@@ -285,17 +285,25 @@
Block b;
b.m_list_p = &wide;
- if (wide.m_dir == DIR_X) {
- b.m_xmin = wide[widemin].m_pos;
- b.m_xmax = wide[widemax].m_pos;
- b.m_ymin = narrow[narrowmin].m_pos;
- b.m_ymax = narrow[narrowmax].m_pos;
+ if (wide.m_dir == DIR_X) {
+
+ // minx, miny, maxx, maxy
+ liblas::Bounds<double> bnd(wide[widemin].m_pos, narrow[narrowmin].m_pos, wide[widemax].m_pos, narrow[narrowmax].m_pos);
+ b.SetBounds(bnd);
+
+ // b.m_xmin = wide[widemin].m_pos;
+ // b.m_xmax = wide[widemax].m_pos;
+ // b.m_ymin = narrow[narrowmin].m_pos;
+ // b.m_ymax = narrow[narrowmax].m_pos;
}
else {
- b.m_xmin = narrow[narrowmin].m_pos;
- b.m_xmax = narrow[narrowmax].m_pos;
- b.m_ymin = wide[widemin].m_pos;
- b.m_ymax = wide[widemax].m_pos;
+ liblas::Bounds<double> bnd(narrow[narrowmin].m_pos, wide[widemin].m_pos, narrow[narrowmax].m_pos, wide[widemax].m_pos);
+ b.SetBounds(bnd);
+
+ // b.m_xmin = narrow[narrowmin].m_pos;
+ // b.m_xmax = narrow[narrowmax].m_pos;
+ // b.m_ymin = wide[widemin].m_pos;
+ // b.m_ymax = wide[widemax].m_pos;
}
b.m_left = widemin;
b.m_right = widemax;
diff -r 92878748f048 -r 244af56577e7 apps/chipper.hpp
--- a/apps/chipper.hpp Tue Aug 10 15:53:44 2010 -0500
+++ b/apps/chipper.hpp Wed Aug 11 11:23:05 2010 -0500
@@ -69,21 +69,24 @@
RefList *m_list_p;
boost::uint32_t m_left;
boost::uint32_t m_right;
- double m_xmin;
- double m_ymin;
- double m_xmax;
- double m_ymax;
+ liblas::Bounds<double> m_bounds;
+ // double m_xmin;
+ // double m_ymin;
+ // double m_xmax;
+ // double m_ymax;
public:
std::vector<boost::uint32_t> GetIDs() const;
- double GetXmin() const
- { return m_xmin; }
- double GetYmin() const
- { return m_ymin; }
- double GetXmax() const
- { return m_xmax; }
- double GetYmax() const
- { return m_ymax; }
+ liblas::Bounds<double> const& GetBounds() const {return m_bounds;}
+ void SetBounds(liblas::Bounds<double> const& bounds) {m_bounds = bounds;}
+ // double GetXmin() const
+ // { return m_xmin; }
+ // double GetYmin() const
+ // { return m_ymin; }
+ // double GetXmax() const
+ // { return m_xmax; }
+ // double GetYmax() const
+ // { return m_ymax; }
};
class Chipper
diff -r 92878748f048 -r 244af56577e7 apps/las2las2.cpp
--- a/apps/las2las2.cpp Tue Aug 10 15:53:44 2010 -0500
+++ b/apps/las2las2.cpp Wed Aug 11 11:23:05 2010 -0500
@@ -316,7 +316,7 @@
("drop-intensity", po::value< string >(), "Range in which to drop intensity.\nThe following expression types are supported: \n--drop-intensity <200 \n--drop-intensity >400 \n--drop-intensity >=200")
("keep-time", po::value< string >(), "Range in which to keep time.\nThe following expression types are supported: \n--keep-time 413665.2336-414092.8462 \n--keep-time <414094.8462 \n--keep-time >413665.2336 \n--keep-time >=413665.2336")
("drop-time", po::value< string >(), "Range in which to drop time.\nThe following expression types are supported: \n--drop-time <413666.2336 \n--drop-time >413665.2336 \n--drop-time >=413665.2336")
- ("verbose,v", po::value<bool>(&verbose)->zero_tokens(), "Keep only valid points")
+ ("verbose,v", po::value<bool>(&verbose)->zero_tokens(), "Verbose message output")
("a_srs", po::value< string >(), "Coordinate system to assign to input LAS file")
("t_srs", po::value< string >(), "Coordinate system to reproject output LAS file to. Use --a_srs or verify that your input LAS file has a coordinate system according to lasinfo")
("offset", po::value< string >(), "A comma-separated list of offsets to set on the output file: \n--offset 0,0,0 \n--offset min,min,min\n ")
diff -r 92878748f048 -r 244af56577e7 apps/lasblock.cpp
--- a/apps/lasblock.cpp Tue Aug 10 15:53:44 2010 -0500
+++ b/apps/lasblock.cpp Wed Aug 11 11:23:05 2010 -0500
@@ -21,17 +21,42 @@
#define compare_no_case(a,b,n) strncasecmp( (a), (b), (n) )
#endif
+#include <boost/program_options.hpp>
-void usage() {
- std::cout << "----------------------------------------------------------\n";
- std::cout << " lasblock (version ) usage:\n";
- std::cout << "----------------------------------------------------------\n";
-
- std::cout << " lasblock filename.las -c 1000 \n";
- std::cout << "--capacity: (-c) capacity of the blocks\n";
-
+namespace po = boost::program_options;
+
+bool term_progress(std::ostream& os, double complete)
+{
+ static int lastTick = -1;
+ int tick = static_cast<int>(complete * 40.0);
+
+ tick = std::min(40, std::max(0, tick));
+
+ // Have we started a new progress run?
+ if (tick < lastTick && lastTick >= 39)
+ lastTick = -1;
+
+ if (tick <= lastTick)
+ return true;
+
+ while (tick > lastTick)
+ {
+ lastTick++;
+ if (lastTick % 4 == 0)
+ os << (lastTick / 4) * 10;
+ else
+ os << ".";
+ }
+
+ if( tick == 40 )
+ os << " - done.\n";
+ else
+ os.flush();
+
+ return true;
}
+
using namespace liblas;
@@ -40,87 +65,82 @@
std::string input;
std::string output;
- long capacity = 10000;
+ long capacity = 3000;
+ long precision = 8;
+ bool verbose = false;
+
+ po::options_description desc("Allowed lasblock options");
+ po::positional_options_description p;
+ p.add("input", 1);
+ p.add("output", 1);
+
+ desc.add_options()
+ ("help,h", "Produce this help message")
+ ("capacity,c", po::value<long>(&capacity)->default_value(3000), "Number of points to nominally put into each block (note that this number will not be exact)")
+ ("precision,p", po::value<long>(&precision)->default_value(8), "Number of decimal points to write for each bbox")
+ ("input,i", po::value< std::string >(), "input LAS file")
+ ("output,o", po::value< std::string >(&output)->default_value(""), "The output .kdx file (defaults to input filename + .kdx)")
+ ("verbose,v", po::value<bool>(&verbose)->zero_tokens(), "Verbose message output")
+
+ ;
- for (int i = 1; i < argc; i++)
+ po::variables_map vm;
+ po::store(po::command_line_parser(argc, argv).
+ options(desc).positional(p).run(), vm);
+
+ po::notify(vm);
+
+ if (vm.count("help"))
{
- if ( std::strcmp(argv[i],"-h") == 0 ||
- std::strcmp(argv[i],"--help") == 0
- )
+ std::cout << desc << "\n";
+ return 1;
+ }
+
+ if (vm.count("input"))
+ {
+ input = vm["input"].as< std::string >();
+ std::ifstream ifs;
+
+ if (!liblas::Open(ifs, input.c_str()))
{
- usage();
- exit(0);
+ std::cerr << "Cannot open file '" << input << "'for read. Exiting...";
+ return 1;
}
- else if ( std::strcmp(argv[i],"--input") == 0 ||
- std::strcmp(argv[i],"-input") == 0 ||
- std::strcmp(argv[i],"-i") == 0 ||
- std::strcmp(argv[i],"-in") == 0
- )
- {
- i++;
- input = std::string(argv[i]);
- }
-
- else if ( strcmp(argv[i],"--output") == 0 ||
- strcmp(argv[i],"--out") == 0 ||
- strcmp(argv[i],"-out") == 0 ||
- strcmp(argv[i],"-o") == 0
- )
- {
- i++;
- output = std::string(argv[i]) + ".kdx";
- }
-
- else if ( std::strcmp(argv[i],"--capacity") == 0 ||
- std::strcmp(argv[i],"-cap") == 0 ||
- std::strcmp(argv[i],"-c") == 0
- )
- {
- i++;
- capacity = atoi(argv[i]);
- }
-
- else if (input.empty())
- {
- input = std::string(argv[i]);
- }
-
- else if (output.empty())
- {
- output = std::string(input) + ".kdx";
- }
-
- else
- {
- usage();
- exit(1);
- }
- }
+ }
- if (input.empty()) {
- usage();
- exit(-1);
- }
if (output.empty())
{
output = std::string(input) + ".kdx";
}
- std::ifstream in(input.c_str());
+ std::ifstream in;
+ if (!liblas::Open(in, input.c_str()))
+ {
+ std::cerr << "Cannot open " << input << "for read. Exiting...";
+ return 1;
+ }
+
std::ofstream out(output.c_str());
liblas::Reader reader( in );
liblas::chipper::Chipper c(&reader, capacity);
+
+ if (verbose)
+ std::cout << "Blocking " << input<< " to " << output <<std::endl;
+
c.Chip();
-
- std::cout << "Blocking " << input<< " to " << output <<std::endl;
+
boost::uint32_t num_blocks = c.GetBlockCount();
- std::cout << "Block count: " << num_blocks << std::endl;
+ if (verbose)
+ std::cout << "Writing " << num_blocks << " blocks to " << output << std::endl;
+
+ boost::uint32_t prog = 0;
+
for ( boost::uint32_t i = 0; i < num_blocks; ++i )
{
const liblas::chipper::Block& b = c.GetBlock(i);
@@ -128,18 +148,23 @@
More information about the Liblas-commits
mailing list