[Liblas-commits] r1004 - in trunk: include/liblas include/liblas/detail python/tests src src/detail

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Feb 9 22:34:17 EST 2009


Author: hobu
Date: Mon Feb  9 22:34:16 2009
New Revision: 1004
URL: http://liblas.org/changeset/1004

Log:
reorganize LASReader.  Tests (cppUnit and Python) all still pass

Modified:
   trunk/include/liblas/detail/fwd.hpp
   trunk/include/liblas/detail/reader.hpp
   trunk/include/liblas/detail/reader10.hpp
   trunk/include/liblas/detail/reader11.hpp
   trunk/include/liblas/detail/reader12.hpp
   trunk/include/liblas/detail/utility.hpp
   trunk/include/liblas/laspoint.hpp
   trunk/include/liblas/lasreader.hpp
   trunk/python/tests/File.txt
   trunk/src/detail/reader.cpp
   trunk/src/detail/reader10.cpp
   trunk/src/detail/reader11.cpp
   trunk/src/detail/reader12.cpp
   trunk/src/laspoint.cpp
   trunk/src/lasreader.cpp

Modified: trunk/include/liblas/detail/fwd.hpp
==============================================================================
--- trunk/include/liblas/detail/fwd.hpp	(original)
+++ trunk/include/liblas/detail/fwd.hpp	Mon Feb  9 22:34:16 2009
@@ -55,6 +55,7 @@
 class Reader;
 class Writer;
 struct PointRecord;
+struct Color;
 
 }} // namespace liblas::detail
 

Modified: trunk/include/liblas/detail/reader.hpp
==============================================================================
--- trunk/include/liblas/detail/reader.hpp	(original)
+++ trunk/include/liblas/detail/reader.hpp	Mon Feb  9 22:34:16 2009
@@ -59,13 +59,12 @@
     virtual ~Reader();
     virtual std::size_t GetVersion() const = 0;
     virtual bool ReadHeader(LASHeader& header) = 0;
-    virtual bool ReadNextPoint(PointRecord& record) = 0;
-    virtual bool ReadNextPoint(PointRecord& record, double& time) = 0;
-    virtual bool ReadPointAt(std::size_t n, PointRecord& record) = 0;
-    virtual bool ReadPointAt(std::size_t n, PointRecord& record, double& time) = 0;
+    virtual bool ReadNextPoint(LASPoint& point, const LASHeader& header) = 0;
+    virtual bool ReadPointAt(std::size_t n, LASPoint& point, const LASHeader& header) = 0;
     virtual bool ReadVLR(LASHeader& header) = 0;
     virtual bool ReadGeoreference(LASHeader& header) = 0; 
     virtual std::istream& GetStream() const = 0;
+    void FillPoint(PointRecord& record, LASPoint& point);
     
 protected:
     

Modified: trunk/include/liblas/detail/reader10.hpp
==============================================================================
--- trunk/include/liblas/detail/reader10.hpp	(original)
+++ trunk/include/liblas/detail/reader10.hpp	Mon Feb  9 22:34:16 2009
@@ -58,10 +58,8 @@
     ReaderImpl(std::istream& ifs);
     std::size_t GetVersion() const;
     bool ReadHeader(LASHeader& header);
-    bool ReadNextPoint(PointRecord& record);
-    bool ReadNextPoint(PointRecord& record, double& time);
-    bool ReadPointAt(std::size_t n, PointRecord& record);
-    bool ReadPointAt(std::size_t n, PointRecord& record, double& time);
+    bool ReadNextPoint(LASPoint& point, const LASHeader& header);
+    bool ReadPointAt(std::size_t n, LASPoint& record, const LASHeader& header);
     bool ReadVLR(LASHeader& header);
     bool ReadGeoreference(LASHeader& header); 
     std::istream& GetStream() const;

Modified: trunk/include/liblas/detail/reader11.hpp
==============================================================================
--- trunk/include/liblas/detail/reader11.hpp	(original)
+++ trunk/include/liblas/detail/reader11.hpp	Mon Feb  9 22:34:16 2009
@@ -58,10 +58,8 @@
     ReaderImpl(std::istream& ifs);
     std::size_t GetVersion() const;
     bool ReadHeader(LASHeader& header);
-    bool ReadNextPoint(detail::PointRecord& record);
-    bool ReadNextPoint(detail::PointRecord& record, double& time);
-    bool ReadPointAt(std::size_t n, PointRecord& record);
-    bool ReadPointAt(std::size_t n, PointRecord& record, double& time);
+    bool ReadNextPoint(LASPoint& point, const LASHeader& header);
+    bool ReadPointAt(std::size_t n, LASPoint& record, const LASHeader& header);
     bool ReadGeoreference(LASHeader& header); 
     bool ReadVLR(LASHeader& header);
     std::istream& GetStream() const;

Modified: trunk/include/liblas/detail/reader12.hpp
==============================================================================
--- trunk/include/liblas/detail/reader12.hpp	(original)
+++ trunk/include/liblas/detail/reader12.hpp	Mon Feb  9 22:34:16 2009
@@ -58,10 +58,8 @@
     ReaderImpl(std::istream& ifs);
     std::size_t GetVersion() const;
     bool ReadHeader(LASHeader& header);
-    bool ReadNextPoint(detail::PointRecord& record);
-    bool ReadNextPoint(detail::PointRecord& record, double& time);
-    bool ReadPointAt(std::size_t n, PointRecord& record);
-    bool ReadPointAt(std::size_t n, PointRecord& record, double& time);
+    bool ReadNextPoint(LASPoint& point, const LASHeader& header);
+    bool ReadPointAt(std::size_t n, LASPoint& record, const LASHeader& header);
     bool ReadGeoreference(LASHeader& header); 
     bool ReadVLR(LASHeader& header);
     std::istream& GetStream() const;

Modified: trunk/include/liblas/detail/utility.hpp
==============================================================================
--- trunk/include/liblas/detail/utility.hpp	(original)
+++ trunk/include/liblas/detail/utility.hpp	Mon Feb  9 22:34:16 2009
@@ -193,6 +193,17 @@
     uint16_t point_source_id; // 1.0: User Bit field / 1.1: Point Source ID
 };
 
+struct Color
+{
+    Color() :
+        red(0), blue(0), green(0) 
+    {}
+    
+    uint16_t red;
+    uint16_t blue;
+    uint16_t green;
+};
+
 template <typename T> 
 bool compare_distance(const T& actual, const T& expected);
 

Modified: trunk/include/liblas/laspoint.hpp
==============================================================================
--- trunk/include/liblas/laspoint.hpp	(original)
+++ trunk/include/liblas/laspoint.hpp	Mon Feb  9 22:34:16 2009
@@ -44,6 +44,7 @@
 
 #include <liblas/cstdint.hpp>
 #include <liblas/detail/fwd.hpp>
+#include <liblas/detail/utility.hpp>
 // std
 #include <stdexcept> // std::out_of_range
 #include <cstdlib> // std::size_t
@@ -187,6 +188,9 @@
     bool Validate() const;
     bool IsValid() const;
     
+    /// Scale the coordinates by the Offset and Scale in the given header
+    void ScaleCoordinates(const LASHeader& header);
+    
 private:
 
     static std::size_t const coords_size = 3;
@@ -198,10 +202,10 @@
     uint8_t m_userData;
     uint16_t m_pointSourceId;
     double m_gpsTime;
-    uint16_t m_red;
-    uint16_t m_green;
-    uint16_t m_blue;
-
+    
+    detail::Color m_color;
+    detail::PointRecord m_rec;
+    
     void throw_out_of_range() const
     {
         throw std::out_of_range("coordinate subscript out of range");
@@ -343,32 +347,32 @@
 
 inline uint16_t LASPoint::GetRed() const
 {
-    return m_red;
+    return m_color.red;
 }
 
 inline void LASPoint::SetRed(uint16_t const& value)
 {
-    m_red = value;
+    m_color.red = value;
 }
 
 inline uint16_t LASPoint::GetBlue() const
 {
-    return m_blue;
+    return m_color.blue;
 }
 
 inline void LASPoint::SetBlue(uint16_t const& value)
 {
-    m_blue = value;
+    m_color.blue = value;
 }
 
 inline uint16_t LASPoint::GetGreen() const
 {
-    return m_green;
+    return m_color.green;
 }
 
 inline void LASPoint::SetGreen(uint16_t const& value)
 {
-    m_green = value;
+    m_color.green = value;
 }
 
 inline double& LASPoint::operator[](std::size_t const& n)

Modified: trunk/include/liblas/lasreader.hpp
==============================================================================
--- trunk/include/liblas/lasreader.hpp	(original)
+++ trunk/include/liblas/lasreader.hpp	Mon Feb  9 22:34:16 2009
@@ -96,7 +96,7 @@
     std::auto_ptr<detail::Reader> m_pimpl;
     LASHeader m_header;
     LASPoint m_point;
-    detail::PointRecord m_record;
+//    detail::PointRecord m_record;
     std::vector<LASVLR> m_vlrs;
 
 };

Modified: trunk/python/tests/File.txt
==============================================================================
--- trunk/python/tests/File.txt	(original)
+++ trunk/python/tests/File.txt	Mon Feb  9 22:34:16 2009
@@ -97,4 +97,9 @@
   
   >>> f.close()
   >>> import os
-  >>> os.remove('junk.las')
\ No newline at end of file
+  >>> os.remove('junk.las')
+
+  >>> f = file.File('junk.las2')
+  Traceback (most recent call last):
+  ...
+  LASException: LASError in "LASReader_Create": can not open file /Users/hobu/svn/liblas/trunk/python/junk.las2

Modified: trunk/src/detail/reader.cpp
==============================================================================
--- trunk/src/detail/reader.cpp	(original)
+++ trunk/src/detail/reader.cpp	Mon Feb  9 22:34:16 2009
@@ -62,6 +62,20 @@
 {
 }
 
+void Reader::FillPoint(PointRecord& record, LASPoint& point) 
+{
+    
+    point.SetX(record.x);
+    point.SetY(record.y);
+    point.SetZ(record.z);
+    point.SetIntensity(record.intensity);
+    point.SetScanFlags(record.flags);
+    point.SetClassification(record.classification);
+    point.SetScanAngleRank(record.scan_angle_rank);
+    point.SetUserData(record.user_data);
+    point.SetPointSourceID(record.point_source_id);
+}
+
 Reader* ReaderFactory::Create(std::istream& ifs)
 {
     if (!ifs)

Modified: trunk/src/detail/reader10.cpp
==============================================================================
--- trunk/src/detail/reader10.cpp	(original)
+++ trunk/src/detail/reader10.cpp	Mon Feb  9 22:34:16 2009
@@ -153,13 +153,22 @@
 
     // 16. Point Data Format ID
     read_n(n1, m_ifs, sizeof(n1));
-    if (n1 == LASHeader::ePointFormat0)
+    if (n1 == LASHeader::ePointFormat0) {
         header.SetDataFormatId(LASHeader::ePointFormat0);
-    else if (n1 == LASHeader::ePointFormat1)
+    } 
+    else if (n1 == LASHeader::ePointFormat1) {
         header.SetDataFormatId(LASHeader::ePointFormat1);
-    else
+    }
+    else if (n1 == LASHeader::ePointFormat2) {
+        header.SetDataFormatId(LASHeader::ePointFormat2);
+    }
+    else if (n1 == LASHeader::ePointFormat3) {
+        header.SetDataFormatId(LASHeader::ePointFormat3);
+    }
+    else {
         throw std::domain_error("invalid point data format");
-
+    }
+    
     // 17. Point Data Record Length
     // NOTE: No need to set record length because it's
     // determined on basis of point data format.
@@ -243,7 +252,7 @@
 
         header.AddVLR(vlr);
     }
-    
+
     return true;
 }
 
@@ -293,7 +302,7 @@
 
             header.SetProj4(tmp);
         }
-
+        
         return true;
     }
 
@@ -302,11 +311,15 @@
     return false;
 }
 
-bool ReaderImpl::ReadNextPoint(detail::PointRecord& record)
+bool ReaderImpl::ReadNextPoint(LASPoint& point, const LASHeader& header)
 {
     // Read point data record format 0
 
     // TODO: Replace with compile-time assert
+    
+    detail::PointRecord record;
+    double t=0;
+    
     assert(LASHeader::ePointSize0 == sizeof(record));
 
     if (0 == m_current)
@@ -328,33 +341,43 @@
             return false;
         }
 
+        Reader::FillPoint(record, point);
+        point.ScaleCoordinates(header);
+        
+        if (header.GetDataFormatId() == LASHeader::ePointFormat1) {
+            detail::read_n(t, m_ifs, sizeof(double));
+            point.SetTime(t);
+        }
         return true;
     }
 
     return false;
 }
 
-bool ReaderImpl::ReadNextPoint(detail::PointRecord& record, double& time)
-{
-    // Read point data record format 1
-
-    // TODO: Replace with compile-time assert
-    assert(LASHeader::ePointSize1 == sizeof(record) + sizeof(time));
+// bool ReaderImpl::ReadNextPoint(LASPoint& point, double& time)
+// {
+//     // Read point data record format 1
+// 
+//     
+//     
+//     assert(LASHeader::ePointSize1 == sizeof(record) + sizeof(time));
+// 
+//     bool hasData = ReadNextPoint(record);
+//     if (hasData)
+//     {
+//         detail::read_n(time, m_ifs, sizeof(double));
+//     }
+// 
+//     return hasData;
+// }
 
-    bool hasData = ReadNextPoint(record);
-    if (hasData)
-    {
-        detail::read_n(time, m_ifs, sizeof(double));
-    }
-
-    return hasData;
-}
-
-bool ReaderImpl::ReadPointAt(std::size_t n, PointRecord& record)
+bool ReaderImpl::ReadPointAt(std::size_t n, LASPoint& point, const LASHeader& header)
 {
     // Read point data record format 0
 
     // TODO: Replace with compile-time assert
+    double t=0;
+    detail::PointRecord record;
     assert(LASHeader::ePointSize0 == sizeof(record));
 
     if (m_size <= n)
@@ -366,25 +389,33 @@
     m_ifs.seekg(pos, std::ios::beg);
     detail::read_n(record, m_ifs, sizeof(record));
 
-    return true;
-}
-
-bool ReaderImpl::ReadPointAt(std::size_t n, PointRecord& record, double& time)
-{
-    // Read point data record format 1
-
-    // TODO: Replace with compile-time assert
-    assert(LASHeader::ePointSize1 == sizeof(record) + sizeof(time));
-
-    bool hasData = ReadPointAt(n, record);
-    if (hasData)
-    {
-        detail::read_n(time, m_ifs, sizeof(double));
+    Reader::FillPoint(record, point);
+    point.ScaleCoordinates(header);
+    
+    if (header.GetDataFormatId() == LASHeader::ePointFormat1) {
+        detail::read_n(t, m_ifs, sizeof(double));
+        point.SetTime(t);
     }
 
-    return hasData;
+    return true;
 }
 
+// bool ReaderImpl::ReadPointAt(std::size_t n, PointRecord& record, double& time)
+// {
+//     // Read point data record format 1
+// 
+//     // TODO: Replace with compile-time assert
+//     assert(LASHeader::ePointSize1 == sizeof(record) + sizeof(time));
+// 
+//     bool hasData = ReadPointAt(n, record);
+//     if (hasData)
+//     {
+//         detail::read_n(time, m_ifs, sizeof(double));
+//     }
+// 
+//     return hasData;
+// }
+
 std::istream& ReaderImpl::GetStream() const
 {
     return m_ifs;

Modified: trunk/src/detail/reader11.cpp
==============================================================================
--- trunk/src/detail/reader11.cpp	(original)
+++ trunk/src/detail/reader11.cpp	Mon Feb  9 22:34:16 2009
@@ -157,13 +157,22 @@
 
     // 17. Point Data Format ID
     read_n(n1, m_ifs, sizeof(n1));
-    if (n1 == LASHeader::ePointFormat0)
+    if (n1 == LASHeader::ePointFormat0) {
         header.SetDataFormatId(LASHeader::ePointFormat0);
-    else if (n1 == LASHeader::ePointFormat1)
+    } 
+    else if (n1 == LASHeader::ePointFormat1) {
         header.SetDataFormatId(LASHeader::ePointFormat1);
-    else
+    }
+    else if (n1 == LASHeader::ePointFormat2) {
+        header.SetDataFormatId(LASHeader::ePointFormat2);
+    }
+    else if (n1 == LASHeader::ePointFormat3) {
+        header.SetDataFormatId(LASHeader::ePointFormat3);
+    }
+    else {
         throw std::domain_error("invalid point data format");
-
+    }
+    
     // 18. Point Data Record Length
     // NOTE: No need to set record length because it's
     // determined on basis of point data format.
@@ -216,11 +225,14 @@
     return true;
 }
 
-bool ReaderImpl::ReadNextPoint(detail::PointRecord& record)
+bool ReaderImpl::ReadNextPoint(LASPoint& point, const LASHeader& header)
 {
     // Read point data record format 0
 
     // TODO: Replace with compile-time assert
+
+    double t = 0;
+    detail::PointRecord record;
     assert(LASHeader::ePointSize0 == sizeof(record));
 
     if (0 == m_current)
@@ -242,33 +254,28 @@
             return false;
         }
 
+        Reader::FillPoint(record, point);
+        point.ScaleCoordinates(header);
+    
+        if (header.GetDataFormatId() == LASHeader::ePointFormat1) {
+            detail::read_n(t, m_ifs, sizeof(double));
+            point.SetTime(t);
+        }
         return true;
     }
 
     return false;
 }
 
-bool ReaderImpl::ReadNextPoint(detail::PointRecord& record, double& time)
-{
-    // Read point data record format 1
-
-    // TODO: Replace with compile-time assert
-    assert(LASHeader::ePointSize1 == sizeof(record) + sizeof(time));
-
-    bool hasData = ReadNextPoint(record);
-    if (hasData)
-    {
-        detail::read_n(time, m_ifs, sizeof(double));
-    }
 
-    return hasData;
-}
-
-bool ReaderImpl::ReadPointAt(std::size_t n, PointRecord& record)
+bool ReaderImpl::ReadPointAt(std::size_t n, LASPoint& point, const LASHeader& header)
 {
     // Read point data record format 0
 
     // TODO: Replace with compile-time assert
+
+    double t = 0;
+    detail::PointRecord record;
     assert(LASHeader::ePointSize0 == sizeof(record));
 
     if (m_size <= n)
@@ -280,23 +287,14 @@
     m_ifs.seekg(pos, std::ios::beg);
     detail::read_n(record, m_ifs, sizeof(record));
 
-    return true;
-}
-
-bool ReaderImpl::ReadPointAt(std::size_t n, PointRecord& record, double& time)
-{
-    // Read point data record format 1
-
-    // TODO: Replace with compile-time assert
-    assert(LASHeader::ePointSize1 == sizeof(record) + sizeof(time));
-
-    bool hasData = ReadPointAt(n, record);
-    if (hasData)
-    {
-        detail::read_n(time, m_ifs, sizeof(double));
+    Reader::FillPoint(record, point);
+    point.ScaleCoordinates(header);
+    
+    if (header.GetDataFormatId() == LASHeader::ePointFormat1) {
+        detail::read_n(t, m_ifs, sizeof(double));
+        point.SetTime(t);
     }
-
-    return hasData;
+    return true;
 }
 
 std::istream& ReaderImpl::GetStream() const

Modified: trunk/src/detail/reader12.cpp
==============================================================================
--- trunk/src/detail/reader12.cpp	(original)
+++ trunk/src/detail/reader12.cpp	Mon Feb  9 22:34:16 2009
@@ -225,11 +225,14 @@
     return true;
 }
 
-bool ReaderImpl::ReadNextPoint(detail::PointRecord& record)
+bool ReaderImpl::ReadNextPoint(LASPoint& point, const LASHeader& header)
 {
     // Read point data record format 0
 
     // TODO: Replace with compile-time assert
+
+    double t = 0;
+    detail::PointRecord record;
     assert(LASHeader::ePointSize0 == sizeof(record));
 
     if (0 == m_current)
@@ -250,34 +253,46 @@
             std::cerr << e.what() << std::endl;
             return false;
         }
-
+        
+        Reader::FillPoint(record, point);
+        point.ScaleCoordinates(header);
+    
+        // TODO: not working yet for the various point formats
+        // if (header.GetDataFormatId() == LASHeader::ePointFormat1) {
+        //     detail::read_n(t, m_ifs, sizeof(double));
+        //     point.SetTime(t);
+        // }
+        
         return true;
     }
 
     return false;
 }
 
-bool ReaderImpl::ReadNextPoint(detail::PointRecord& record, double& time)
-{
-    // Read point data record format 1
-
-    // TODO: Replace with compile-time assert
-    assert(LASHeader::ePointSize1 == sizeof(record) + sizeof(time));
-
-    bool hasData = ReadNextPoint(record);
-    if (hasData)
-    {
-        detail::read_n(time, m_ifs, sizeof(double));
-    }
-
-    return hasData;
-}
+// bool ReaderImpl::ReadNextPoint(detail::PointRecord& record, double& time)
+// {
+//     // Read point data record format 1
+// 
+//     // TODO: Replace with compile-time assert
+//     assert(LASHeader::ePointSize1 == sizeof(record) + sizeof(time));
+// 
+//     bool hasData = ReadNextPoint(record);
+//     if (hasData)
+//     {
+//         detail::read_n(time, m_ifs, sizeof(double));
+//     }
+// 
+//     return hasData;
+// }
 
-bool ReaderImpl::ReadPointAt(std::size_t n, PointRecord& record)
+bool ReaderImpl::ReadPointAt(std::size_t n, LASPoint& point, const LASHeader& header)
 {
     // Read point data record format 0
 
     // TODO: Replace with compile-time assert
+    
+    double t = 0;
+    detail::PointRecord record;
     assert(LASHeader::ePointSize0 == sizeof(record));
 
     if (m_size <= n)
@@ -289,25 +304,33 @@
     m_ifs.seekg(pos, std::ios::beg);
     detail::read_n(record, m_ifs, sizeof(record));
 
-    return true;
-}
-
-bool ReaderImpl::ReadPointAt(std::size_t n, PointRecord& record, double& time)
-{
-    // Read point data record format 1
-
-    // TODO: Replace with compile-time assert
-    assert(LASHeader::ePointSize1 == sizeof(record) + sizeof(time));
+    Reader::FillPoint(record, point);
+    point.ScaleCoordinates(header);
 
-    bool hasData = ReadPointAt(n, record);
-    if (hasData)
-    {
-        detail::read_n(time, m_ifs, sizeof(double));
+    if (header.GetDataFormatId() == LASHeader::ePointFormat1) {
+        detail::read_n(t, m_ifs, sizeof(double));
+        point.SetTime(t);
     }
-
-    return hasData;
+        
+    return true;
 }
 
+// bool ReaderImpl::ReadPointAt(std::size_t n, PointRecord& record, double& time)
+// {
+//     // Read point data record format 1
+// 
+//     // TODO: Replace with compile-time assert
+//     assert(LASHeader::ePointSize1 == sizeof(record) + sizeof(time));
+// 
+//     bool hasData = ReadPointAt(n, record);
+//     if (hasData)
+//     {
+//         detail::read_n(time, m_ifs, sizeof(double));
+//     }
+// 
+//     return hasData;
+// }
+
 std::istream& ReaderImpl::GetStream() const
 {
     return m_ifs;

Modified: trunk/src/laspoint.cpp
==============================================================================
--- trunk/src/laspoint.cpp	(original)
+++ trunk/src/laspoint.cpp	Mon Feb  9 22:34:16 2009
@@ -56,12 +56,12 @@
     m_angleRank(0),
     m_userData(0),
     m_pointSourceId(0),
-    m_gpsTime(0),
-    m_red(0),
-    m_green(0),
-    m_blue(0)
+    m_gpsTime(0)
 {
     std::memset(m_coords, 0, sizeof(m_coords));
+    m_color.red = 0;
+    m_color.blue = 0;
+    m_color.green = 0;    
 }
 
 LASPoint::LASPoint(LASPoint const& other) :
@@ -71,12 +71,12 @@
     m_angleRank(other.m_angleRank),
     m_userData(other.m_userData),
     m_pointSourceId(other.m_pointSourceId),
-    m_gpsTime(other.m_gpsTime),
-    m_red(other.m_red),
-    m_green(other.m_green),
-    m_blue(other.m_blue)
+    m_gpsTime(other.m_gpsTime)
 {
     std::memcpy(m_coords, other.m_coords, sizeof(m_coords));
+    m_color.red = other.m_color.red;
+    m_color.blue = other.m_color.blue;
+    m_color.green = other.m_color.green;
 }
 
 LASPoint& LASPoint::operator=(LASPoint const& rhs)
@@ -93,9 +93,9 @@
         m_userData = rhs.m_userData;
         m_pointSourceId = rhs.m_pointSourceId;
         m_gpsTime = rhs.m_gpsTime;
-        m_red = rhs.m_red;
-        m_green = rhs.m_green;
-        m_blue = rhs.m_blue;
+        m_color.red = rhs.m_color.red;
+        m_color.blue = rhs.m_color.blue;
+        m_color.green = rhs.m_color.green;
     }
     return *this;
 }
@@ -236,4 +236,16 @@
 
     return true;
 }
+
+void LASPoint::ScaleCoordinates(const LASHeader& header) 
+{
+
+    double const x = GetX() * header.GetScaleX() + header.GetOffsetX();
+    double const y = GetY() * header.GetScaleY() + header.GetOffsetY();
+    double const z = GetZ() * header.GetScaleZ() + header.GetOffsetZ();
+     
+    SetCoordinates(x, y, z);
+        
+}
+
 } // namespace liblas

Modified: trunk/src/lasreader.cpp
==============================================================================
--- trunk/src/lasreader.cpp	(original)
+++ trunk/src/lasreader.cpp	Mon Feb  9 22:34:16 2009
@@ -83,19 +83,8 @@
 bool LASReader::ReadNextPoint()
 {
     bool ret = false;
-    double time = 0;
     
-//    std::cout << "Format id: " << m_header.GetDataFormatId() << std::endl;
-    
-    if (m_header.GetDataFormatId() == LASHeader::ePointFormat0)
-        ret = m_pimpl->ReadNextPoint(m_record);
-    else
-        ret = m_pimpl->ReadNextPoint(m_record, time);
-
-    if (ret)
-    {
-        MakePoint(time);
-    }
+    ret = m_pimpl->ReadNextPoint(m_point, m_header);
 
     return ret;
 }
@@ -103,17 +92,8 @@
 bool LASReader::ReadPointAt(std::size_t n)
 {
     bool ret = false;
-    double time = 0;
 
-    if (m_header.GetDataFormatId() == LASHeader::ePointFormat0)
-        ret = m_pimpl->ReadPointAt(n, m_record);
-    else
-        ret = m_pimpl->ReadPointAt(n, m_record, time);
-
-    if (ret)
-    {
-        MakePoint(time);
-    }
+    ret = m_pimpl->ReadPointAt(n, m_point, m_header);
 
     return ret;
 }
@@ -126,19 +106,14 @@
     }
 
     bool ret = false;
-    double time = 0;
 
-    if (m_header.GetDataFormatId() == LASHeader::ePointFormat0)
-        ret = m_pimpl->ReadPointAt(n, m_record);
-    else
-        ret = m_pimpl->ReadPointAt(n, m_record, time);
+    ret = m_pimpl->ReadPointAt(n, m_point, m_header);
 
     if (!ret)
     {
         throw std::out_of_range("no point record at given position");
     }
 
-    MakePoint(time);
 
     return m_point;
 }
@@ -165,18 +140,18 @@
 
 void LASReader::MakePoint(double const& time)
 {
-    double const x = m_record.x * m_header.GetScaleX() + m_header.GetOffsetX();
-    double const y = m_record.y * m_header.GetScaleY() + m_header.GetOffsetY();
-    double const z = m_record.z * m_header.GetScaleZ() + m_header.GetOffsetZ();
-
-    m_point.SetCoordinates(x, y, z);
-    m_point.SetIntensity(m_record.intensity);
-    m_point.SetScanFlags(m_record.flags);
-    m_point.SetClassification(m_record.classification);
-    m_point.SetScanAngleRank(m_record.scan_angle_rank);
-    m_point.SetUserData(m_record.user_data);
-    m_point.SetPointSourceID(m_record.point_source_id);
-    m_point.SetTime(time);
+    // double const x = m_record.x * m_header.GetScaleX() + m_header.GetOffsetX();
+    // double const y = m_record.y * m_header.GetScaleY() + m_header.GetOffsetY();
+    // double const z = m_record.z * m_header.GetScaleZ() + m_header.GetOffsetZ();
+    // 
+    // m_point.SetCoordinates(x, y, z);
+    // m_point.SetIntensity(m_record.intensity);
+    // m_point.SetScanFlags(m_record.flags);
+    // m_point.SetClassification(m_record.classification);
+    // m_point.SetScanAngleRank(m_record.scan_angle_rank);
+    // m_point.SetUserData(m_record.user_data);
+    // m_point.SetPointSourceID(m_record.point_source_id);
+    // m_point.SetTime(time);
 }
 
 std::istream& LASReader::GetStream() const


More information about the Liblas-commits mailing list