[Liblas-commits] hg-main-tree: fix up ScalingFilter to copy non-XYZ data, appears...

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Jul 21 14:30:32 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/9df6751d8129
changeset: 905:9df6751d8129
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Jul 21 13:25:24 2011 -0500
description:
fix up ScalingFilter to copy non-XYZ data, appears to work now
Subject: hg-main-tree: remove lint

details:   http://hg.libpc.orghg-main-tree/rev/66539fbcbfab
changeset: 906:66539fbcbfab
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Jul 21 13:25:33 2011 -0500
description:
remove lint
Subject: hg-main-tree: remove lint

details:   http://hg.libpc.orghg-main-tree/rev/a7d8a462ad9b
changeset: 907:a7d8a462ad9b
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Jul 21 13:28:46 2011 -0500
description:
remove lint
Subject: hg-main-tree: merge

details:   http://hg.libpc.orghg-main-tree/rev/fa41ca1b1b9c
changeset: 908:fa41ca1b1b9c
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Jul 21 13:30:25 2011 -0500
description:
merge

diffstat:

 include/pdal/PointBuffer.hpp    |   2 +-
 src/filters/ScalingFilter.cpp   |  44 ++++++++++++++++++++++++++--------------
 test/unit/ScalingFilterTest.cpp |  14 ++++++------
 3 files changed, 36 insertions(+), 24 deletions(-)

diffs (138 lines):

diff -r 9ad3e85bd7c1 -r fa41ca1b1b9c include/pdal/PointBuffer.hpp
--- a/include/pdal/PointBuffer.hpp	Thu Jul 21 11:45:36 2011 -0500
+++ b/include/pdal/PointBuffer.hpp	Thu Jul 21 13:30:25 2011 -0500
@@ -204,7 +204,7 @@
     Dimension const& d = dl.getDimension();
     std::size_t offset = (pointIndex * m_pointSize) + dl.getByteOffset();
     std::size_t size = d.getDataTypeSize(d.getDataType());
-    std::cout << "copying field " << fieldIndex << " of size " << size << " at offset " << offset << std::endl;
+    // std::cout << "copying field " << d.getFieldName() << " with index" << fieldIndex << " of size " << size << " at offset " << offset << std::endl;
     // assert(offset + sizeof(T) <= m_pointSize * m_capacity);
     boost::uint8_t* p = m_data.get() + offset;
     
diff -r 9ad3e85bd7c1 -r fa41ca1b1b9c src/filters/ScalingFilter.cpp
--- a/src/filters/ScalingFilter.cpp	Thu Jul 21 11:45:36 2011 -0500
+++ b/src/filters/ScalingFilter.cpp	Thu Jul 21 13:30:25 2011 -0500
@@ -229,10 +229,6 @@
     // rather than think about "src/dst", we will think in terms of "doubles" and "ints"
     const Schema& schemaD = (m_forward ? srcSchema : dstSchema);
     const Schema& schemaI = (m_forward ? dstSchema : srcSchema);
-    
-    // std::cout << " Source Schema: " << std::endl << srcSchema << std::endl;
-    // std::cout << " DST Schema: " << std::endl << dstSchema << std::endl;
-    
 
     assert(schemaD.hasDimension(Dimension::Field_X, Dimension::Double));
     assert(schemaI.hasDimension(Dimension::Field_X, Dimension::Int32));
@@ -268,6 +264,28 @@
             const boost::int32_t yi = dimYi.removeScaling<boost::int32_t>(yd);
             const boost::int32_t zi = dimZi.removeScaling<boost::int32_t>(zd);
 
+            const boost::uint8_t* src_raw_data = srcData.getData(pointIndex);
+            boost::uint8_t* dst_raw_data = dstData.getData(pointIndex);
+
+
+            boost::uint32_t srcFieldIndex = 0;
+            boost::uint32_t dstFieldIndex = 0;
+            for (std::vector<DimensionLayout>::const_iterator i = src_layouts.begin(); i != src_layouts.end(); ++i)
+            {
+
+                Dimension const& d = i->getDimension();
+                std::size_t src_offset = i->getByteOffset();
+                
+                if (d != dimXd && d != dimYd && d != dimZd)
+                {
+                    dstFieldIndex = dstSchemaLayout.getSchema().getDimensionIndex(d);
+                    srcFieldIndex = srcSchemaLayout.getSchema().getDimensionIndex(d);
+                    std::size_t size = d.getDataTypeSize(d.getDataType());
+
+                    dstData.setFieldData(pointIndex, dstFieldIndex, src_raw_data+src_offset);
+                }
+            }
+
             dstData.setField<boost::int32_t>(pointIndex, indexXi, xi);
             dstData.setField<boost::int32_t>(pointIndex, indexYi, yi);
             dstData.setField<boost::int32_t>(pointIndex, indexZi, zi);
@@ -279,7 +297,8 @@
             // ints --> doubles  (applyScaling)
             const boost::int32_t xi = srcData.getField<boost::int32_t>(pointIndex, indexXi);
             const boost::int32_t yi = srcData.getField<boost::int32_t>(pointIndex, indexYi);
-            const boost::int32_t zi = srcData.getField<boost::int32_t>(pointIndex, indexZi);
+            const boost::int32_t zi = srcData.getField<boost::int32_t>(pointIndex, indexZi);    
+
 
             const double xd = dimXd.applyScaling(xi);
             const double yd = dimYd.applyScaling(yi);
@@ -288,8 +307,6 @@
             const boost::uint8_t* src_raw_data = srcData.getData(pointIndex);
             boost::uint8_t* dst_raw_data = dstData.getData(pointIndex);
 
-            std::size_t src_position = 0;
-            std::size_t dst_position = 0;
             boost::uint32_t srcFieldIndex = 0;
             boost::uint32_t dstFieldIndex = 0;
             for (std::vector<DimensionLayout>::const_iterator i = src_layouts.begin(); i != src_layouts.end(); ++i)
@@ -300,15 +317,10 @@
                 
                 if (d != dimXi && d != dimYi && d != dimZi)
                 {
-                dstFieldIndex = dstSchemaLayout.getSchema().getDimensionIndex(d);
-                srcFieldIndex = srcSchemaLayout.getSchema().getDimensionIndex(d);
-                std::size_t size = d.getDataTypeSize(d.getDataType());
-                
-                std::cout << " src osffset: " << src_offset
-                          << " srcFieldIndex: " << srcFieldIndex 
-                          << " dstFieldIndex: " << dstFieldIndex  
-                          << std::endl;
-                dstData.setFieldData(pointIndex, dstFieldIndex, src_raw_data+src_offset);
+                    dstFieldIndex = dstSchemaLayout.getSchema().getDimensionIndex(d);
+                    srcFieldIndex = srcSchemaLayout.getSchema().getDimensionIndex(d);
+                    std::size_t size = d.getDataTypeSize(d.getDataType());
+                    dstData.setFieldData(pointIndex, dstFieldIndex, src_raw_data+src_offset);
 
 
                 }
diff -r 9ad3e85bd7c1 -r fa41ca1b1b9c test/unit/ScalingFilterTest.cpp
--- a/test/unit/ScalingFilterTest.cpp	Thu Jul 21 11:45:36 2011 -0500
+++ b/test/unit/ScalingFilterTest.cpp	Thu Jul 21 13:30:25 2011 -0500
@@ -52,7 +52,7 @@
 
 
 static void getDoublePoint(const pdal::PointBuffer& data, double& x, double& y, double& z, 
-                            boost::uint16_t& intensity, boost::int16_t scan_angle, boost::uint16_t green)
+                            boost::uint16_t& intensity, boost::int8_t& scan_angle, boost::uint16_t& green)
 {
     using namespace pdal;
 
@@ -61,15 +61,15 @@
     const int indexX = schema.getDimensionIndex(Dimension::Field_X, Dimension::Double);
     const int indexY = schema.getDimensionIndex(Dimension::Field_Y, Dimension::Double);
     const int indexZ = schema.getDimensionIndex(Dimension::Field_Z, Dimension::Double);
-    const int indexIntensity = schema.getDimensionIndex(Dimension::Field_Intensity, Dimension::Uint16);
-    const int indexScanAngle = schema.getDimensionIndex(Dimension::Field_ScanAngleRank, Dimension::Int16);
+    const int indexIntensity = schema.getDimensionIndex(Dimension::Field_Intensity, Dimension::Uint8);
+    const int indexScanAngle = schema.getDimensionIndex(Dimension::Field_ScanAngleRank, Dimension::Int8);
     const int indexGreen = schema.getDimensionIndex(Dimension::Field_Green, Dimension::Uint16);
 
 
     x = data.getField<double>(0, indexX);
     y = data.getField<double>(0, indexY);
     z = data.getField<double>(0, indexZ);
-    scan_angle = data.getField<boost::int16_t>(0, indexScanAngle);
+    scan_angle = data.getField<boost::int8_t>(0, indexScanAngle);
     intensity = data.getField<boost::uint16_t>(0, indexIntensity);
     green = data.getField<boost::uint16_t>(0, indexGreen);
 
@@ -100,9 +100,9 @@
         delete iter;
 
         double x=0, y=0, z=0;
-        boost::uint16_t intensity;
-        boost::int16_t scan_angle;
-        boost::uint16_t green;
+        boost::uint16_t intensity(0);
+        boost::int8_t scan_angle(06);
+        boost::uint16_t green(0);
         getDoublePoint(data2, x, y, z, intensity, scan_angle, green);
 
         BOOST_CHECK_CLOSE(x, 470692.44, 1);


More information about the Liblas-commits mailing list