[Liblas-commits] hg: 6 new changesets

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Aug 11 14:32:26 EDT 2010


changeset 4aec8c6b9119 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=4aec8c6b9119
summary: update in light of cmake builds

changeset 74082e122d63 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=74082e122d63
summary: remove assertion that time must be >=0.  Time is relative to the header in many cases, so negative times can be allowed

changeset 3d8a6fa166c2 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=3d8a6fa166c2
summary: add scan angle filtering

changeset 9b765e18a6d8 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=9b765e18a6d8
summary: add las file that has real color values

changeset fc54eaed1d1a in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=fc54eaed1d1a
summary: add ColorFilter to filter for ranges of colors on points

changeset d7975db2a1a1 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=d7975db2a1a1
summary: add ColorFilter support

diffstat:

 INSTALL                      |   38 +-------------
 apps/las2las2.cpp            |  114 ++++++++++++++++++++++++++++++++++++++++++-
 include/liblas/lasfilter.hpp |   26 +++++++++
 include/liblas/laspoint.hpp  |    2 +-
 src/lasfilter.cpp            |   53 +++++++++++++++++++
 test/data/1.2-with-color.las |    0 
 6 files changed, 196 insertions(+), 37 deletions(-)

diffs (truncated from 315 to 300 lines):

diff -r 244af56577e7 -r d7975db2a1a1 INSTALL
--- a/INSTALL	Wed Aug 11 11:23:05 2010 -0500
+++ b/INSTALL	Wed Aug 11 13:32:14 2010 -0500
@@ -3,38 +3,6 @@
 ***************************************************************
 
  
-Unix
-~~~~~~~~~~~~~~~~~~~
-
-libLAS uses a typical GNU autoconf/automake framework for 
-building and installation on unix-like platforms.  
-
-The quick and dirty installation that would install things 
-by default in /usr/local might look like:
-
-::
-
-    ./configure
-    make
-    make install
-
-Configure libLAS for debugging and install in my home directory:
-
-::
-
-    ./configure --enable-debug --prefix=/home/hobu/liblas
-
-If you are building directly from subversion, you will need to generate 
-the configure script first.  This will require that your system have
-autotools installed.
-
-::
-
-	./autogen.sh
-    
-Windows
-~~~~~~~~~~~~~~~~~~~
-
-Copy the windows package zip file into a directory of your 
-choosing and unzip.  You should be able to run the utility 
-applications.
+See http://liblas.org/compilation.html for details how to build 
+libLAS from source.  See http://liblas.org/download.html for 
+locations to download pre-built binaries of libLAS.
diff -r 244af56577e7 -r d7975db2a1a1 apps/las2las2.cpp
--- a/apps/las2las2.cpp	Wed Aug 11 11:23:05 2010 -0500
+++ b/apps/las2las2.cpp	Wed Aug 11 13:32:14 2010 -0500
@@ -176,7 +176,6 @@
     return intensity_filter;
 }
 
-
 liblas::FilterI*  MakeTimeFilter(std::string times, liblas::FilterI::FilterType ftype) 
 {
     liblas::ContinuousValueFilter<double>::filter_func f = &liblas::Point::GetTime;
@@ -185,6 +184,20 @@
     return time_filter;
 }
 
+liblas::FilterI*  MakeScanAngleFilter(std::string intensities, liblas::FilterI::FilterType ftype) 
+{
+    liblas::ContinuousValueFilter<int8_t>::filter_func f = &liblas::Point::GetScanAngleRank;
+    liblas::ContinuousValueFilter<int8_t>* intensity_filter = new liblas::ContinuousValueFilter<int8_t>(f, intensities);
+    intensity_filter->SetType(ftype);
+    return intensity_filter;
+}
+
+liblas::FilterI* MakeColorFilter(liblas::Color const& low, liblas::Color const& high, liblas::FilterI::FilterType ftype)
+{
+    liblas::ColorFilter* filter = new liblas::ColorFilter(low, high);
+    filter->SetType(ftype);
+    return filter;
+}
 
 bool process(   std::string const& input,
                 std::string const& output,
@@ -316,6 +329,11 @@
             ("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")
+            ("keep-scan-angle", po::value< string >(), "Range in which to keep scan angle.\nThe following expression types are supported:  \n--keep-scan-angle 0-100 \n--keep-scan-angle <100\n--keep-scan-angle <=100")
+            ("drop-scan-angle", po::value< string >(), "Range in which to drop scan angle.\nThe following expression types are supported:  \n--drop-scan-angle <30 \n--drop-scan-angle >100 \n--drop-scan-angle >=100")
+            ("keep-color", po::value< string >(), "Range in which to keep colors.\nDefine colors as two 3-tuples (R,G,B-R,G,B):  \n--keep-color '0,0,0-125,125,125'")
+            ("drop-color", po::value< string >(), "Range in which to drop colors.\nDefine colors as two 3-tuples (R,G,B-R,G,B):  \n--drop-color '255,255,255-65536,65536,65536'")
+
             ("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")   
@@ -446,6 +464,43 @@
                 filters.push_back(intensity_filter);   
             }
         }
+        if (vm.count("keep-scan-angle")) 
+        {
+            std::string angles = vm["keep-scan-angle"].as< string >();
+            if (verbose)
+                std::cout << "Keeping scan angles with values: " << angles << std::endl;
+            if (IsDualRangeFilter(angles)) {
+                // We need to make two filters
+                // Given a range 0-200, split the expression into two filters 
+                string::size_type dash = angles.find_first_of("-");
+                std::string low = angles.substr(0,dash);
+                std::string high = angles.substr(dash+1, angles.size());
+
+                liblas::FilterI* lt_filter = MakeScanAngleFilter(">="+low, liblas::FilterI::eInclusion);
+                filters.push_back(lt_filter);
+                liblas::FilterI* gt_filter = MakeScanAngleFilter("<="+high, liblas::FilterI::eInclusion);
+                filters.push_back(gt_filter);                
+            } else {
+                liblas::FilterI* angle_filter = MakeScanAngleFilter(angles, liblas::FilterI::eInclusion);
+                filters.push_back(angle_filter);
+                
+            }
+        }
+        if (vm.count("drop-scan-angle")) 
+        {
+            std::string angles = vm["drop-scan-angle"].as< string >();
+            if (verbose)
+                std::cout << "Dropping scan angles with values: " << angles << std::endl;
+
+            if (IsDualRangeFilter(angles)) {
+                std::cerr << "Range filters are not supported for drop-scan-angle" << std::endl;
+                return(1);
+            } else {
+                liblas::FilterI* angle_filter = MakeScanAngleFilter(angles, liblas::FilterI::eExclusion);
+                filters.push_back(angle_filter);   
+            }
+        }
+        
         if (vm.count("keep-time")) 
         {
             std::string times = vm["keep-time"].as< string >();
@@ -526,6 +581,60 @@
             transforms.push_back(srs_transform);
         }
 
+        if (vm.count("keep-color")) 
+        {
+            std::string keepers = vm["keep-color"].as< string >();
+            if (verbose)
+                std::cout << "Keeping colors in range:: " << keepers << std::endl;
+                
+            // Pull apart color ranges in the form: R,G,B-R,G,B
+            boost::char_separator<char> sep_dash("-");
+            boost::char_separator<char> sep_comma(",");
+            std::vector<liblas::Color> colors;
+            tokenizer low_high(keepers, sep_dash);
+            for (tokenizer::iterator t = low_high.begin(); t != low_high.end(); ++t) {
+                
+                tokenizer rgbs((*t), sep_comma);
+                std::vector<liblas::Color::value_type> rgb;
+                for(tokenizer::iterator c = rgbs.begin(); c != rgbs.end(); ++c)
+                {
+                    rgb.push_back(atof((*c).c_str()));
+                }
+                liblas::Color color(rgb[0], rgb[1], rgb[2]);
+                colors.push_back(color);
+            }
+            
+            liblas::FilterI* color_filter = MakeColorFilter(colors[0], colors[1], liblas::FilterI::eInclusion);
+            filters.push_back(color_filter);
+        }
+        if (vm.count("drop-color")) 
+        {
+            std::string dropers = vm["drop-color"].as< string >();
+            if (verbose)
+                std::cout << "Dropping colors in range:: " << dropers << std::endl;
+                
+            // Pull apart color ranges in the form: R,G,B-R,G,B
+            boost::char_separator<char> sep_dash("-");
+            boost::char_separator<char> sep_comma(",");
+            std::vector<liblas::Color> colors;
+            tokenizer low_high(dropers, sep_dash);
+            for (tokenizer::iterator t = low_high.begin(); t != low_high.end(); ++t) {
+                
+                tokenizer rgbs((*t), sep_comma);
+                std::vector<liblas::Color::value_type> rgb;
+                for(tokenizer::iterator c = rgbs.begin(); c != rgbs.end(); ++c)
+                {
+                    rgb.push_back(atof((*c).c_str()));
+                }
+                liblas::Color color(rgb[0], rgb[1], rgb[2]);
+                colors.push_back(color);
+            }
+            
+            liblas::FilterI* color_filter = MakeColorFilter(colors[0], colors[1], liblas::FilterI::eExclusion);
+            filters.push_back(color_filter);
+        }
+
+
         if (vm.count("offset")) 
         {
             std::string offset_string = vm["offset"].as< string >();
@@ -603,6 +712,9 @@
         }
         if (thin > 0) 
         {
+            if (verbose)
+                std::cout << "Thining file by keeping every "<<thin<<"'th point "  << std::endl;
+                
             liblas::ThinFilter* thin_filter = new ThinFilter(thin);
             filters.push_back(thin_filter);    
         }
diff -r 244af56577e7 -r d7975db2a1a1 include/liblas/lasfilter.hpp
--- a/include/liblas/lasfilter.hpp	Wed Aug 11 11:23:05 2010 -0500
+++ b/include/liblas/lasfilter.hpp	Wed Aug 11 13:32:14 2010 -0500
@@ -339,6 +339,32 @@
 
 };
 
+
+class ColorFilter: public FilterI
+{
+public:
+
+    ColorFilter(liblas::Color const& low, 
+                liblas::Color const& high);
+                
+    ColorFilter(liblas::Color::value_type low_red, 
+                liblas::Color::value_type high_red,
+                liblas::Color::value_type low_blue,
+                liblas::Color::value_type high_blue,
+                liblas::Color::value_type low_green,
+                liblas::Color::value_type high_green);
+    bool filter(const Point& point);
+    
+private:
+    
+    liblas::Color m_low;
+    liblas::Color m_high;
+
+    ColorFilter(ColorFilter const& other);
+    ColorFilter& operator=(ColorFilter const& rhs);
+    bool DoExclude();
+};
+
 } // namespace liblas
 
 #endif // ndef LIBLAS_LASFILTER_HPP_INCLUDED
diff -r 244af56577e7 -r d7975db2a1a1 include/liblas/laspoint.hpp
--- a/include/liblas/laspoint.hpp	Wed Aug 11 11:23:05 2010 -0500
+++ b/include/liblas/laspoint.hpp	Wed Aug 11 13:32:14 2010 -0500
@@ -332,7 +332,7 @@
 
 inline void Point::SetTime(double const& time)
 {
-    assert(time >= 0); // TODO: throw? --mloskot
+    // assert(time >= 0); // TODO: throw? --mloskot  // negative times are legit, I think -- hobu
     m_gps_time = time;
 }
 
diff -r 244af56577e7 -r d7975db2a1a1 src/lasfilter.cpp
--- a/src/lasfilter.cpp	Wed Aug 11 11:23:05 2010 -0500
+++ b/src/lasfilter.cpp	Wed Aug 11 13:32:14 2010 -0500
@@ -233,4 +233,57 @@
 }
 
 
+ColorFilter::ColorFilter(liblas::Color const& low, liblas::Color const& high) :
+ liblas::FilterI(eInclusion), m_low(low), m_high(high)
+{
+
+}
+
+ColorFilter::ColorFilter(liblas::Color::value_type low_red, 
+                liblas::Color::value_type high_red,
+                liblas::Color::value_type low_blue,
+                liblas::Color::value_type high_blue,
+                liblas::Color::value_type low_green,
+                liblas::Color::value_type high_green) :
+ liblas::FilterI(eInclusion), m_low(low_red, low_green, low_blue), m_high(high_red, high_blue, high_green)
+{
+
+}
+
+bool ColorFilter::DoExclude()
+{
+    if (GetType() == eInclusion) {
+        return true;
+    } else {
+        return false;
+    }  
+}
+
+
+bool ColorFilter::filter(const liblas::Point& p)
+{
+
+    liblas::Color const& c = p.GetColor();
+    
+    if (c.GetRed() < m_low.GetRed())
+        return !DoExclude();
+    
+    if (c.GetRed() > m_high.GetRed())
+        return !DoExclude();
+
+    if (c.GetBlue() < m_low.GetBlue())
+        return !DoExclude();
+    


More information about the Liblas-commits mailing list