[Liblas-commits] hg-main-tree: don't override getPointCout

liblas-commits at liblas.org liblas-commits at liblas.org
Wed May 11 13:05:52 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/0dd14aa5fea2
changeset: 709:0dd14aa5fea2
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed May 11 12:04:33 2011 -0500
description:
don't override getPointCout
Subject: hg-main-tree: TerraSolid reader now working

details:   http://hg.libpc.orghg-main-tree/rev/9f91166cbf42
changeset: 710:9f91166cbf42
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed May 11 12:05:38 2011 -0500
description:
TerraSolid reader now working

diffstat:

 include/libpc/drivers/qfit/Reader.hpp        |    2 -
 include/libpc/drivers/terrasolid/Reader.hpp  |    1 -
 src/drivers/terrasolid/Reader.cpp            |   36 ++++++++++++++++++---------
 test/data/terrasolid/20020715-time-color.bin |    0 
 test/unit/TerraSolidTest.cpp                 |   26 ++++++++++---------
 5 files changed, 38 insertions(+), 27 deletions(-)

diffs (195 lines):

diff -r e8f2efe44b86 -r 9f91166cbf42 include/libpc/drivers/qfit/Reader.hpp
--- a/include/libpc/drivers/qfit/Reader.hpp	Wed May 11 10:49:55 2011 -0500
+++ b/include/libpc/drivers/qfit/Reader.hpp	Wed May 11 12:05:38 2011 -0500
@@ -136,8 +136,6 @@
         
         return false;
     }
-
-    boost::uint64_t getNumPoints() { return 0; }
     
     libpc::SequentialIterator* createSequentialIterator() const;
     libpc::RandomIterator* createRandomIterator() const;
diff -r e8f2efe44b86 -r 9f91166cbf42 include/libpc/drivers/terrasolid/Reader.hpp
--- a/include/libpc/drivers/terrasolid/Reader.hpp	Wed May 11 10:49:55 2011 -0500
+++ b/include/libpc/drivers/terrasolid/Reader.hpp	Wed May 11 12:05:38 2011 -0500
@@ -145,7 +145,6 @@
         return false;
     }
 
-    boost::uint64_t getNumPoints() { return 0; }
     
     libpc::SequentialIterator* createSequentialIterator() const;
     libpc::RandomIterator* createRandomIterator() const;
diff -r e8f2efe44b86 -r 9f91166cbf42 src/drivers/terrasolid/Reader.cpp
--- a/src/drivers/terrasolid/Reader.cpp	Wed May 11 10:49:55 2011 -0500
+++ b/src/drivers/terrasolid/Reader.cpp	Wed May 11 12:05:38 2011 -0500
@@ -103,7 +103,7 @@
     m_header.swap(h);
     Utils::read_n(*m_header, *stream, sizeof(TerraSolidHeader));
 
-    std::cout << "RecogVal: " << m_header->RecogVal << std::endl;
+    // std::cout << "RecogVal: " << m_header->RecogVal << std::endl;
     if ( m_header->RecogVal != 970401)
         throw terrasolid_error("Header identifier was not '970401', is this a TerraSolid .bin file?");
 
@@ -114,6 +114,7 @@
     m_haveTime = static_cast<bool>(m_header->Time);
     m_format = static_cast<TERRASOLID_Format_Type>(m_header->HdrVersion);
     
+    
     if ( !( (m_format==TERRASOLID_Format_1) || (m_format == TERRASOLID_Format_2) ) )
     {
         std::ostringstream oss;
@@ -124,16 +125,20 @@
 
     registerFields();
     
-    std::cout << "format: " << m_format << std::endl;
-    std::cout << "OrgX: " << m_header->OrgX << std::endl;
-    std::cout << "OrgY: " << m_header->OrgY << std::endl;
-    std::cout << "OrgZ: " << m_header->OrgZ << std::endl;
-    std::cout << "Units: " << m_header->Units << std::endl;
-    std::cout << "Time: " << m_header->Time << std::endl;
-    std::cout << "Color: " << m_header->Color << std::endl;
-    std::cout << "Count: " << m_header->PntCnt << std::endl;
+    m_offset = 56;
+    SchemaLayout layout(getSchemaRef());
+    m_size = layout.getByteSize();
+    
+    // std::cout << "format: " << m_format << std::endl;
+    // std::cout << "OrgX: " << m_header->OrgX << std::endl;
+    // std::cout << "OrgY: " << m_header->OrgY << std::endl;
+    // std::cout << "OrgZ: " << m_header->OrgZ << std::endl;
+    // std::cout << "Units: " << m_header->Units << std::endl;
+    // std::cout << "Time: " << m_header->Time << std::endl;
+    // std::cout << "Color: " << m_header->Color << std::endl;
+    // std::cout << "Count: " << m_header->PntCnt << std::endl;
    
-    getSchemaRef().dump();
+    // getSchemaRef().dump();
     delete stream;
 }    
 
@@ -275,6 +280,8 @@
         Dimension time(Dimension::Field_Time, Dimension::Uint32);
         text << "32 bit integer time stamps. Time stamps are assumed to be GPS week seconds. The storage format is a 32 bit unsigned integer where each integer step is 0.0002 seconds.";
         time.setDescription(text.str());
+        time.setNumericScale(0.0002);
+        time.setNumericOffset(0.0);
         schema.addDimension(time);
         text.str("");
     }
@@ -392,7 +399,7 @@
 
         if (m_format == TERRASOLID_Format_2) 
         {
-
+            // std::cout << "Reading TERRASOLID_Format_2" << std::endl;
             boost::int32_t x = Utils::read_field<boost::int32_t>(p);
             data.setField<boost::int32_t>(pointIndex, indexes.X, x);
             
@@ -401,7 +408,9 @@
             
             boost::int32_t z = Utils::read_field<boost::int32_t>(p);
             data.setField<boost::int32_t>(pointIndex, indexes.Z, z);
-
+            
+            // std::cout << "x: " << x << " y: " << y << " z: " << z << std::endl;
+            
             boost::uint8_t classification = Utils::read_field<boost::uint8_t>(p);
             data.setField<boost::uint8_t>(pointIndex, indexes.Classification, classification);
             
@@ -426,6 +435,7 @@
             {
                 boost::uint32_t time = Utils::read_field<boost::uint32_t>(p);
                 data.setField<boost::uint32_t>(pointIndex, indexes.Time, time);
+                // std::cout << "We have time " << time << std::endl;
             }
             
             if (indexes.Red != -1)
@@ -441,6 +451,8 @@
 
                 boost::uint8_t alpha = Utils::read_field<boost::uint8_t>(p);
                 data.setField<boost::uint8_t>(pointIndex, indexes.Alpha, alpha);
+                // std::cout << "Red: " << (int)red << " Green: " << (int)green << " Blue: " << (int)blue << std::endl;
+
             }
         }
 
diff -r e8f2efe44b86 -r 9f91166cbf42 test/data/terrasolid/20020715-time-color.bin
Binary file test/data/terrasolid/20020715-time-color.bin has changed
diff -r e8f2efe44b86 -r 9f91166cbf42 test/unit/TerraSolidTest.cpp
--- a/test/unit/TerraSolidTest.cpp	Wed May 11 10:49:55 2011 -0500
+++ b/test/unit/TerraSolidTest.cpp	Wed May 11 12:05:38 2011 -0500
@@ -56,7 +56,7 @@
 void Check_Point(const libpc::PointBuffer& data, const ::libpc::Schema& schema, 
                        std::size_t index, 
                        double xref, double yref, double zref,
-                       boost::int32_t tref)
+                       double tref)
 {
 
     int offsetX = schema.getDimensionIndex(libpc::Dimension::Field_X, libpc::Dimension::Int32);
@@ -67,23 +67,24 @@
     boost::int32_t x = data.getField<boost::int32_t>(index, offsetX);
     boost::int32_t y = data.getField<boost::int32_t>(index, offsetY);
     boost::int32_t z = data.getField<boost::int32_t>(index, offsetZ);
-    boost::int32_t t = data.getField<boost::uint32_t>(index, offsetTime);
+    boost::uint32_t t = data.getField<boost::uint32_t>(index, offsetTime);
 
     double x0 = schema.getDimension(offsetX).applyScaling<boost::int32_t>(x);
     double y0 = schema.getDimension(offsetY).applyScaling<boost::int32_t>(y);
     double z0 = schema.getDimension(offsetZ).applyScaling<boost::int32_t>(z);
+    double t0 = schema.getDimension(offsetTime).applyScaling<boost::uint32_t>(t);
 
   
-    std::cout.setf(std::ios_base::fixed, std::ios_base::floatfield);
-    std::cout.precision(6);
-    std::cout << "expected x: " << xref << " y: " << yref << " z: " << zref << " t: " << tref << std::endl;
-    
-    std::cout << "actual   x: " << x0 << " y: " << y0 << " z: " << z0 << " t: " << t << std::endl;
+    // std::cout.setf(std::ios_base::fixed, std::ios_base::floatfield);
+    // std::cout.precision(6);
+    // std::cout << "expected x: " << xref << " y: " << yref << " z: " << zref << " t: " << tref << std::endl;
+    // 
+    // std::cout << "actual   x: " << x0 << " y: " << y0 << " z: " << z0 << " t0: " << t0 << std::endl;
     
     Compare(x0, xref);
     Compare(y0, yref);
     Compare(z0, zref);
-    BOOST_CHECK_EQUAL(t, tref);
+    Compare(t0, tref);
 }
 
 BOOST_AUTO_TEST_CASE(test_10_word)
@@ -91,7 +92,7 @@
     libpc::Options options;
     // std::string filename = Support::datapath("20050903_231839.qi");
 
-    std::string filename = Support::datapath("terrasolid/TerraSolid.bin");
+    std::string filename = Support::datapath("terrasolid/20020715-time-color.bin");
 
     
     boost::property_tree::ptree& tree = options.GetPTree();
@@ -99,6 +100,7 @@
     libpc::drivers::terrasolid::Reader reader(options);
     BOOST_CHECK(reader.getDescription() == "TerraSolid Reader");
     BOOST_CHECK_EQUAL(reader.getName(), "drivers.terrasolid.reader");
+    BOOST_CHECK_EQUAL(reader.getNumPoints(), 1000);
 
     const Schema& schema = reader.getSchema();
     SchemaLayout layout(schema);
@@ -113,9 +115,9 @@
     }
 
     
-    Check_Point(data, schema, 0, 59.205160, 221.826822, 32090.0, 0);
-    Check_Point(data, schema, 1, 59.205161, 221.826740, 32019.0, 0);
-    Check_Point(data, schema, 2, 59.205164, 221.826658, 32000.0, 0);
+    Check_Point(data, schema, 0, 363127.94, 3437612.33, 55.26, 580220.5528);
+    Check_Point(data, schema, 1, 363128.12, 3437613.01, 55.33, 580220.5530);
+    Check_Point(data, schema, 2, 363128.29, 3437613.66, 55.28, 580220.5530);
 
 
     return;


More information about the Liblas-commits mailing list