[Liblas-commits] hg-main-tree: update the header's bounds

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Apr 28 11:25:40 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/2c7b904a79a9
changeset: 690:2c7b904a79a9
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Apr 28 08:25:32 2011 -0700
description:
update the header's bounds

diffstat:

 include/libpc/filters/ReprojectionFilter.hpp |   1 +
 src/filters/ReprojectionFilter.cpp           |  23 ++++++++++++++++
 test/unit/ReprojectionFilterTest.cpp         |  38 +++++++++++++++++++++++----
 3 files changed, 56 insertions(+), 6 deletions(-)

diffs (104 lines):

diff -r e13e73cec6b8 -r 2c7b904a79a9 include/libpc/filters/ReprojectionFilter.hpp
--- a/include/libpc/filters/ReprojectionFilter.hpp	Wed Apr 27 16:21:56 2011 -0700
+++ b/include/libpc/filters/ReprojectionFilter.hpp	Thu Apr 28 08:25:32 2011 -0700
@@ -73,6 +73,7 @@
     void processBuffer(PointBuffer& data) const;
 
 private:
+    void updateBounds();
     void checkImpedance();
     void initialize();
     void transform(double& x, double& y, double& z) const;
diff -r e13e73cec6b8 -r 2c7b904a79a9 src/filters/ReprojectionFilter.cpp
--- a/src/filters/ReprojectionFilter.cpp	Wed Apr 27 16:21:56 2011 -0700
+++ b/src/filters/ReprojectionFilter.cpp	Thu Apr 28 08:25:32 2011 -0700
@@ -91,6 +91,29 @@
 
     initialize();
 
+    updateBounds();
+
+    return;
+}
+
+void ReprojectionFilter::updateBounds()
+{
+    const Bounds<double>& oldBounds = getBounds();
+
+    double minx = oldBounds.getMinimum(0);
+    double miny = oldBounds.getMinimum(1);
+    double minz = oldBounds.getMinimum(2);
+    double maxx = oldBounds.getMaximum(0);
+    double maxy = oldBounds.getMaximum(1);
+    double maxz = oldBounds.getMaximum(2);
+
+    transform(minx, miny, minz);
+    transform(maxx, maxy, maxz);
+
+    Bounds<double> newBounds(minx, miny, minz, maxx, maxy, maxz);
+
+    setBounds(newBounds);
+
     return;
 }
 
diff -r e13e73cec6b8 -r 2c7b904a79a9 test/unit/ReprojectionFilterTest.cpp
--- a/test/unit/ReprojectionFilterTest.cpp	Wed Apr 27 16:21:56 2011 -0700
+++ b/test/unit/ReprojectionFilterTest.cpp	Thu Apr 28 08:25:32 2011 -0700
@@ -49,6 +49,17 @@
 BOOST_AUTO_TEST_SUITE(ReprojectionFilterTest)
 
 
+static void compareBounds(const libpc::Bounds<double>& p, const libpc::Bounds<double>& q)
+{
+    BOOST_CHECK_CLOSE(p.getMinimum(0), q.getMinimum(0), 1);
+    BOOST_CHECK_CLOSE(p.getMinimum(1), q.getMinimum(1), 1);
+    BOOST_CHECK_CLOSE(p.getMinimum(2), q.getMinimum(2), 1);
+    BOOST_CHECK_CLOSE(p.getMaximum(0), q.getMaximum(0), 1);
+    BOOST_CHECK_CLOSE(p.getMaximum(1), q.getMaximum(1), 1);
+    BOOST_CHECK_CLOSE(p.getMaximum(2), q.getMaximum(2), 1);
+}
+
+
 static void getPoint(const libpc::PointBuffer& data, boost::uint32_t pointIndex, double& x, double& y, double& z)
 {
     using namespace libpc;
@@ -132,17 +143,32 @@
         delete iter2;
     }
 
+    const double preX = 470692.447538;
+    const double preY = 4602888.904642;
+    const double preZ = 16.000000;
+    const double postX = -93.351563;
+    const double postY = 41.577148;
+    const double postZ = 16.000000;
+
+    // note this file has only 1 points, so yes, the extent's mins and maxes are the same
+    const libpc::Bounds<double> oldBounds_ref(preX, preY, preZ, preX, preY, preZ);
+    const libpc::Bounds<double> newBounds_ref(postX, postY, postZ, postX, postY, postZ);
+    const libpc::Bounds<double>& oldBounds = reader1.getBounds();
+    const libpc::Bounds<double>& newBounds = descalingFilter.getBounds();
+    compareBounds(oldBounds_ref, oldBounds);
+    compareBounds(newBounds_ref, newBounds);
+
     double x1, x2, y1, y2, z1, z2;
     getPoint(data1, 0, x1, y1, z1);
     getPoint(data2, 0, x2, y2, z2);
 
-    BOOST_CHECK_CLOSE(x1, 470692.44, 1);
-    BOOST_CHECK_CLOSE(y1, 4602888.90, 1);
-    BOOST_CHECK_CLOSE(z1, 16, 1);
+    BOOST_CHECK_CLOSE(x1, preX, 1);
+    BOOST_CHECK_CLOSE(y1, preY, 1);
+    BOOST_CHECK_CLOSE(z1, preZ, 1);
 
-    BOOST_CHECK_CLOSE(x2, -93.35156259, 1);
-//////    BOOST_CHECK_CLOSE(y2, 41.57714839, 1); // BUG: I get 90
-//////    BOOST_CHECK_CLOSE(z2, 16, 1); // BUG: I get 0 (no idea what this is supposed to be, not in liblas test)
+    BOOST_CHECK_CLOSE(x2, postX, 1);
+//////    BOOST_CHECK_CLOSE(y2, postY, 1); // BUG: I get 90
+//////    BOOST_CHECK_CLOSE(z2, postZ, 1); // BUG: I get 0 (no idea what this is supposed to be, not in liblas test)
 
     ////////out_hdr->SetScale(0.00000001, 0.00000001, 0.01);
 


More information about the Liblas-commits mailing list