[Liblas-commits] hg: 2 new changesets
liblas-commits at liblas.org
liblas-commits at liblas.org
Fri Sep 24 23:23:38 EDT 2010
changeset a3da354eca52 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=a3da354eca52
summary: rework ClassificationFilter to take in a list of classes. Update the processing kernel to use this with positional arguments
changeset 04c21c394645 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=04c21c394645
summary: fix up extent filtering for the processing kernel
diffstat:
apps/las2las2.cpp | 18 ++--
apps/laskernel.cpp | 181 +++++++++++++++++++++++++++---------------
apps/laskernel.hpp | 6 +-
include/liblas/lasbounds.hpp | 34 ++++++++
include/liblas/lasfilter.hpp | 8 +-
src/lasfilter.cpp | 55 +-----------
6 files changed, 173 insertions(+), 129 deletions(-)
diffs (truncated from 483 to 300 lines):
diff -r 7c35ffbac023 -r 04c21c394645 apps/las2las2.cpp
--- a/apps/las2las2.cpp Fri Sep 24 17:13:09 2010 -0500
+++ b/apps/las2las2.cpp Fri Sep 24 22:23:29 2010 -0500
@@ -314,7 +314,7 @@
liblas::Header header;
- // try {
+ try {
po::options_description file_options("las2las2 options");
po::options_description filtering_options = GetFilteringOptions();
@@ -388,14 +388,14 @@
return (1);
}
- // }
- // catch(std::exception& e) {
- // std::cerr << "error: " << e.what() << "\n";
- // return 1;
- // }
- // catch(...) {
- // std::cerr << "Exception of unknown type!\n";
- // }
+ }
+ catch(std::exception& e) {
+ std::cerr << "error: " << e.what() << "\n";
+ return 1;
+ }
+ catch(...) {
+ std::cerr << "Exception of unknown type!\n";
+ }
return 0;
diff -r 7c35ffbac023 -r 04c21c394645 apps/laskernel.cpp
--- a/apps/laskernel.cpp Fri Sep 24 17:13:09 2010 -0500
+++ b/apps/laskernel.cpp Fri Sep 24 22:23:29 2010 -0500
@@ -12,15 +12,8 @@
return false;
}
-liblas::FilterPtr MakeReturnFilter(std::string return_string, liblas::FilterI::FilterType ftype)
+liblas::FilterPtr MakeReturnFilter(std::vector<boost::uint16_t> const& returns, liblas::FilterI::FilterType ftype)
{
- boost::char_separator<char> sep(SEPARATORS);
-
- std::vector<boost::uint16_t> returns;
- tokenizer tokens(return_string, sep);
- for (tokenizer::iterator t = tokens.begin(); t != tokens.end(); ++t) {
- returns.push_back(atoi((*t).c_str()));
- }
liblas::ReturnFilter* return_filter = new liblas::ReturnFilter(returns, false);
return_filter->SetType(ftype);
@@ -28,50 +21,16 @@
}
-liblas::FilterPtr MakeClassFilter(std::string class_string, liblas::FilterI::FilterType ftype)
+liblas::FilterPtr MakeClassFilter(std::vector<liblas::Classification> const& classes, liblas::FilterI::FilterType ftype)
{
- boost::char_separator<char> sep(SEPARATORS);
-
- std::vector<boost::uint8_t> classes;
- tokenizer tokens(class_string, sep);
- for (tokenizer::iterator t = tokens.begin(); t != tokens.end(); ++t) {
- classes.push_back(atoi((*t).c_str()));
- }
liblas::ClassificationFilter* class_filter = new liblas::ClassificationFilter(classes);
class_filter->SetType(ftype);
return liblas::FilterPtr(class_filter);
}
-liblas::FilterPtr MakeBoundsFilter(std::string bounds_string, liblas::FilterI::FilterType ftype)
+liblas::FilterPtr MakeBoundsFilter(liblas::Bounds<double> const& bounds, liblas::FilterI::FilterType ftype)
{
- boost::char_separator<char> sep(SEPARATORS);
- std::vector<double> vbounds;
- tokenizer tokens(bounds_string, sep);
- liblas::Bounds<double> bounds;
- for (tokenizer::iterator t = tokens.begin(); t != tokens.end(); ++t) {
- vbounds.push_back(atof((*t).c_str()));
- }
- if (vbounds.size() == 4)
- {
- bounds = liblas::Bounds<double>(vbounds[0],
- vbounds[1],
- vbounds[2],
- vbounds[3]);
- } else if (vbounds.size() == 6)
- {
- bounds = liblas::Bounds<double>(vbounds[0],
- vbounds[1],
- vbounds[2],
- vbounds[3],
- vbounds[4],
- vbounds[5]);
- } else {
- ostringstream oss;
- oss << "Bounds must be specified as a 4-tuple or "
- "6-tuple, not a "<< vbounds.size()<<"-tuple" << "\n";
- throw std::runtime_error(oss.str());
- }
liblas::BoundsFilter* bounds_filter = new liblas::BoundsFilter(bounds);
bounds_filter->SetType(ftype);
return liblas::FilterPtr(bounds_filter);
@@ -114,15 +73,15 @@
po::options_description filtering_options("Filtering options");
filtering_options.add_options()
- ("extent,e", po::value< string >(), "Extent window that points must fall within to keep.\nUse a comma-separated list, for example, \n -e minx, miny, maxx, maxy\n or \n -e minx, miny, minz, maxx, maxy, maxz")
+ ("extent,e", po::value< std::vector<double> >()->multitoken(), "Extent window that points must fall within to keep.\nFor example, \n -e minx miny maxx maxy\n or \n -e minx miny minz maxx maxy maxz")
("thin,t", po::value<boost::uint32_t>()->default_value(0), "Simple decimation-style thinning.\nThin the file by removing every t'th point from the file.")
("last_return_only", po::value<bool>()->zero_tokens(), "Keep last returns (cannot be used with --first_return_only)")
("first_return_only", po::value<bool>()->zero_tokens(), "Keep first returns (cannot be used with --last_return_only")
- ("keep-returns", po::value< string >(), "A comma-separated list of return numbers to keep in the output file: \n--keep-returns 1,2,3")
- ("drop-returns", po::value< string >(), "Return numbers to drop.\nUse a comma-separated list, for example, --drop-returns 2,3,4,5")
+ ("keep-returns", po::value< std::vector<boost::uint16_t> >()->multitoken(), "A list of return numbers to keep in the output file: \n--keep-returns 1 2 3")
+ ("drop-returns", po::value< std::vector<boost::uint16_t> >()->multitoken(), "Return numbers to drop.\nFor example, --drop-returns 2 3 4 5")
("valid_only", po::value<bool>()->zero_tokens(), "Keep only valid points")
- ("keep-classes", po::value< string >(), "A comma-separated list of classifications to keep:\n--keep-classes 2,4,12\n--keep-classes 2")
- ("drop-classes", po::value< string >(), "A comma-separated list of classifications to drop:\n--drop-classes 1,7,8\n--drop-classes 2")
+ ("keep-classes", po::value< std::vector<boost::uint32_t > >()->multitoken(), "A list of classifications to keep:\n--keep-classes 2 4 12\n--keep-classes 2")
+ ("drop-classes", po::value< std::vector<boost::uint32_t > >()->multitoken(), "A comma-separated list of classifications to drop:\n--drop-classes 1,7,8\n--drop-classes 2")
("keep-intensity", po::value< string >(), "Range in which to keep intensity.\nThe following expression types are supported: \n--keep-intensity 0-100 \n--keep-intensity <200 \n--keep-intensity >400 \n--keep-intensity >=200")
("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")
@@ -160,32 +119,73 @@
if (vm.count("keep-classes"))
{
- std::string classes = vm["keep-classes"].as< string >();
+ std::vector<boost::uint32_t> classes = vm["keep-classes"].as< std::vector<boost::uint32_t> >();
+
+ std::vector<liblas::Classification> klasses;
+
+ ostringstream oss;
+
+ for (std::vector<boost::uint32_t>::const_iterator i = classes.begin();
+ i != classes.end();
+ i++)
+ {
+ oss << *i << " ";
+ klasses.push_back(liblas::Classification(*i, false, false, false));
+ }
if (verbose)
- std::cout << "Keeping classes with the values: " << classes << std::endl;
+ {
+
+ std::cout << "Keeping classes with the values: " << oss.str() << std::endl;
+ }
+
- liblas::FilterPtr class_filter = MakeClassFilter( classes,
+ liblas::FilterPtr class_filter = MakeClassFilter( klasses,
liblas::FilterI::eInclusion);
filters.push_back(class_filter);
}
if (vm.count("drop-classes"))
{
- std::string classes = vm["drop-classes"].as< string >();
+ std::vector<boost::uint32_t> classes = vm["drop-classes"].as< std::vector<boost::uint32_t> >();
+
+ std::vector<liblas::Classification> klasses;
+
+ ostringstream oss;
+
+ for (std::vector<boost::uint32_t>::const_iterator i = classes.begin();
+ i != classes.end();
+ i++)
+ {
+ oss << *i << " ";
+ klasses.push_back(liblas::Classification(*i,false, false, false));
+ }
if (verbose)
- std::cout << "Dropping classes with the values: " << classes << std::endl;
-
- liblas::FilterPtr class_filter = MakeClassFilter( classes,
+ {
+
+ std::cout << "Dropping classes with the values: " << oss.str() << std::endl;
+ }
+ liblas::FilterPtr class_filter = MakeClassFilter( klasses,
liblas::FilterI::eExclusion);
filters.push_back(class_filter);
}
if (vm.count("keep-returns"))
{
- std::string returns = vm["keep-returns"].as< string >();
+ std::vector<boost::uint16_t> returns = vm["keep-returns"].as< std::vector<boost::uint16_t> >();
+
+
if (verbose)
- std::cout << "Keeping returns with the values: " << returns << std::endl;
-
+ {
+ ostringstream oss;
+ for (std::vector<boost::uint16_t>::const_iterator i = returns.begin();
+ i != returns.end();
+ i++)
+ {
+ oss << *i << " ";
+ }
+ std::cout << "Keeping returns with the values: " << oss.str() << std::endl;
+ }
+
liblas::FilterPtr return_filter = MakeReturnFilter( returns,
liblas::FilterI::eInclusion);
filters.push_back(return_filter);
@@ -193,10 +193,20 @@
if (vm.count("drop-returns"))
{
- std::string returns = vm["drop-returns"].as< string >();
+ std::vector<boost::uint16_t> returns = vm["keep-returns"].as< std::vector<boost::uint16_t> >();
+
if (verbose)
- std::cout << "Dropping returns with the values: " << returns << std::endl;
-
+ {
+ ostringstream oss;
+ for (std::vector<boost::uint16_t>::const_iterator i = returns.begin();
+ i != returns.end();
+ i++)
+ {
+ oss << *i << " ";
+ }
+ std::cout << "Dropping returns with the values: " << oss.str() << std::endl;
+ }
+
liblas::FilterPtr return_filter = MakeReturnFilter( returns,
liblas::FilterI::eExclusion);
filters.push_back(return_filter);
@@ -204,9 +214,52 @@
if (vm.count("extent"))
{
- std::string bounds = vm["extent"].as< string >();
+
+ std::vector<double> vbounds = vm["extent"].as< std::vector<double> >();
+
+ liblas::Bounds<double> bounds;
+
+ if (vbounds.size() == 4)
+ {
+ bounds = liblas::Bounds<double>(vbounds[0],
+ vbounds[1],
+ vbounds[2],
+ vbounds[3]);
+ } else if (vbounds.size() == 6)
+ {
+ bounds = liblas::Bounds<double>(vbounds[0],
+ vbounds[1],
+ vbounds[2],
+ vbounds[3],
+ vbounds[4],
+ vbounds[5]);
+ } else {
+ ostringstream oss;
+ oss << "Bounds must be specified as a 4-tuple or "
+ "6-tuple, not a "<< vbounds.size()<<"-tuple" << "\n";
+ throw std::runtime_error(oss.str());
+ }
+
if (verbose)
- std::cout << "Clipping file to the extent : " << bounds << std::endl;
+ {
+ std::cout << "---------------------------------------------------------" << std::endl;
+ std::cout << " Clipping file to the extent" << std::endl;
+ std::cout << "---------------------------------------------------------" << std::endl;
+
+ std::cout.setf(std::ios_base::fixed, std::ios_base::floatfield);
+ std::cout.precision(6);
+
+ std::cout << " minx: " << bounds.minx()
+ << " miny: " << bounds.miny()
+ << " minz: " << bounds.minz()
+ << std::endl;
+ std::cout << " maxx: " << bounds.maxx()
+ << " maxy: " << bounds.maxy()
+ << " maxz: " << bounds.maxz()
+ << std::endl;
+ std::cout << "---------------------------------------------------------" << std::endl;
+ }
+
liblas::FilterPtr bounds_filter = MakeBoundsFilter(bounds, liblas::FilterI::eInclusion);
filters.push_back(bounds_filter);
diff -r 7c35ffbac023 -r 04c21c394645 apps/laskernel.hpp
--- a/apps/laskernel.hpp Fri Sep 24 17:13:09 2010 -0500
+++ b/apps/laskernel.hpp Fri Sep 24 22:23:29 2010 -0500
@@ -69,9 +69,9 @@
bool IsDualRangeFilter(std::string parse_string) ;
-liblas::FilterPtr MakeReturnFilter(std::string return_string, liblas::FilterI::FilterType ftype) ;
More information about the Liblas-commits
mailing list