[Liblas-commits] libpc: add Crop filter test

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Feb 23 21:19:03 EST 2011


details:   http://hg.liblas.orglibpc/rev/c73b09963765
changeset: 86:c73b09963765
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Wed Feb 23 18:18:58 2011 -0800
description:
add Crop filter test

diffstat:

 src/CropFilter.cpp           |   7 +++++--
 test/unit/CropFilterTest.cpp |  31 ++++++++++++++++++++++++++++++-
 2 files changed, 35 insertions(+), 3 deletions(-)

diffs (65 lines):

diff -r 7b7170b9a018 -r c73b09963765 src/CropFilter.cpp
--- a/src/CropFilter.cpp	Wed Feb 23 18:18:28 2011 -0800
+++ b/src/CropFilter.cpp	Wed Feb 23 18:18:58 2011 -0800
@@ -85,8 +85,11 @@
                 // remove this point, and update the lower bound for Z
                 data.setValid(pointIndex, false);
             }
-
-            ++numValidPoints;
+            else
+            {
+                data.setValid(pointIndex, true);
+                ++numValidPoints;
+            }
         }
     }
 
diff -r 7b7170b9a018 -r c73b09963765 test/unit/CropFilterTest.cpp
--- a/test/unit/CropFilterTest.cpp	Wed Feb 23 18:18:28 2011 -0800
+++ b/test/unit/CropFilterTest.cpp	Wed Feb 23 18:18:58 2011 -0800
@@ -3,14 +3,43 @@
 #include <boost/test/unit_test.hpp>
 #include <boost/cstdint.hpp>
 
+#include "libpc/FauxReader.hpp"
+#include "libpc/FauxWriter.hpp"
 #include "libpc/CropFilter.hpp"
 
 using namespace libpc;
 
 BOOST_AUTO_TEST_SUITE(CropFilterTest)
 
-BOOST_AUTO_TEST_CASE(test_ctor)
+BOOST_AUTO_TEST_CASE(test_crop)
 {
+    Bounds<double> srcBounds(0.0, 0.0, 0.0, 100.0, 100.0, 100.0);
+
+    // crop tjhe window to 1/8th the size
+    Bounds<double> dstBounds(0.0, 0.0, 0.0, 50.0, 50.0, 50.0);
+    
+    FauxReader reader(srcBounds, 1000, FauxReader::Random);
+
+    CropFilter filter(reader, dstBounds);
+
+    FauxWriter writer(filter);
+
+    boost::uint64_t numWritten = writer.write(1000);
+
+    // 1000 * 1/8 = 125, plus or minus 10%
+    BOOST_CHECK(Utils::compare_approx<double>(numWritten, 125, 12.5));
+
+    // test all the values to +/- 10%
+    BOOST_CHECK(Utils::compare_approx<float>(writer.getMinX(), 0.0, 5.0));
+    BOOST_CHECK(Utils::compare_approx<float>(writer.getMinY(), 0.0, 5.0));
+    BOOST_CHECK(Utils::compare_approx<float>(writer.getMinZ(), 0.0, 5.0));
+    BOOST_CHECK(Utils::compare_approx<float>(writer.getMaxX(), 50.0, 5.0));
+    BOOST_CHECK(Utils::compare_approx<float>(writer.getMaxY(), 50.0, 5.0));
+    BOOST_CHECK(Utils::compare_approx<float>(writer.getMaxZ(), 50.0, 5.0));
+    BOOST_CHECK(Utils::compare_approx<float>(writer.getAvgX(), 25.0, 5.0));
+    BOOST_CHECK(Utils::compare_approx<float>(writer.getAvgY(), 25.0, 5.0));
+    BOOST_CHECK(Utils::compare_approx<float>(writer.getAvgZ(), 25.0, 5.0));
+
     return;
 }
 


More information about the Liblas-commits mailing list