[Liblas-commits] r1003 - in trunk: include/liblas include/liblas/detail src src/detail

liblas-commits at liblas.org liblas-commits at liblas.org
Sun Feb 8 20:47:35 EST 2009


Author: hobu
Date: Sun Feb  8 20:47:34 2009
New Revision: 1003
URL: http://liblas.org/changeset/1003

Log:
start in on 1.2 read support.  Tests pass, but 1.2 reading is not working yet

Added:
   trunk/include/liblas/detail/reader12.hpp
      - copied, changed from r1002, /trunk/include/liblas/detail/reader11.hpp
   trunk/include/liblas/detail/writer12.hpp
      - copied, changed from r1002, /trunk/include/liblas/detail/writer11.hpp
   trunk/src/detail/reader12.cpp
      - copied, changed from r1002, /trunk/src/detail/reader11.cpp
   trunk/src/detail/writer12.cpp
      - copied, changed from r1002, /trunk/src/detail/writer11.cpp
Modified:
   trunk/include/liblas/lasheader.hpp
   trunk/include/liblas/liblas.hpp
   trunk/src/Makefile.am
   trunk/src/detail/reader.cpp
   trunk/src/detail/reader11.cpp
   trunk/src/lasheader.cpp
   trunk/src/laspoint.cpp
   trunk/src/lasreader.cpp

Copied: trunk/include/liblas/detail/reader12.hpp (from r1002, /trunk/include/liblas/detail/reader11.hpp)
==============================================================================
--- /trunk/include/liblas/detail/reader11.hpp	(original)
+++ trunk/include/liblas/detail/reader12.hpp	Sun Feb  8 20:47:34 2009
@@ -39,15 +39,15 @@
  * OF SUCH DAMAGE.
  ****************************************************************************/
 
-#ifndef LIBLAS_DETAIL_READER11_HPP_INCLUDED
-#define LIBLAS_DETAIL_READER11_HPP_INCLUDED
+#ifndef LIBLAS_DETAIL_READER12_HPP_INCLUDED
+#define LIBLAS_DETAIL_READER12_HPP_INCLUDED
 
 #include <liblas/detail/reader.hpp>
 #include <liblas/detail/fwd.hpp>
 // std
 #include <iosfwd>
 
-namespace liblas { namespace detail { namespace v11 {
+namespace liblas { namespace detail { namespace v12 {
 
 class ReaderImpl : public Reader
 {
@@ -70,6 +70,6 @@
     std::istream& m_ifs;
 };
 
-}}} // namespace liblas::detail::v11
+}}} // namespace liblas::detail::v12
 
-#endif // LIBLAS_DETAIL_READER11_HPP_INCLUDED
+#endif // LIBLAS_DETAIL_READER12_HPP_INCLUDED

Copied: trunk/include/liblas/detail/writer12.hpp (from r1002, /trunk/include/liblas/detail/writer11.hpp)
==============================================================================
--- /trunk/include/liblas/detail/writer11.hpp	(original)
+++ trunk/include/liblas/detail/writer12.hpp	Sun Feb  8 20:47:34 2009
@@ -39,8 +39,8 @@
  * OF SUCH DAMAGE.
  ****************************************************************************/
 
-#ifndef LIBLAS_DETAIL_WRITER11_HPP_INCLUDED
-#define LIBLAS_DETAIL_WRITER11_HPP_INCLUDED
+#ifndef LIBLAS_DETAIL_WRITER12_HPP_INCLUDED
+#define LIBLAS_DETAIL_WRITER12_HPP_INCLUDED
 
 #include <liblas/detail/writer.hpp>
 #include <liblas/detail/fwd.hpp>
@@ -48,7 +48,7 @@
 // std
 #include <iosfwd>
 
-namespace liblas { namespace detail { namespace v11 {
+namespace liblas { namespace detail { namespace v12 {
 
 class WriterImpl : public Writer
 {
@@ -71,6 +71,6 @@
     liblas::uint32_t m_pointCount;
 };
 
-}}} // namespace liblas::detail::v11
+}}} // namespace liblas::detail::v12
 
-#endif // LIBLAS_DETAIL_WRITER11_HPP_INCLUDED
+#endif // LIBLAS_DETAIL_WRITER12_HPP_INCLUDED

Modified: trunk/include/liblas/lasheader.hpp
==============================================================================
--- trunk/include/liblas/lasheader.hpp	(original)
+++ trunk/include/liblas/lasheader.hpp	Sun Feb  8 20:47:34 2009
@@ -90,7 +90,7 @@
         ePointSize0 = 20, ///< Size of point record in data format \e 0
         ePointSize1 = 28, ///< Size of point record in data format \e 1
         ePointSize2 = 26, ///< Size of point record in data format \e 2
-        ePointSize3 = 32  ///< Size of point record in data format \e 3
+        ePointSize3 = 34  ///< Size of point record in data format \e 3
 
     };
 

Modified: trunk/include/liblas/liblas.hpp
==============================================================================
--- trunk/include/liblas/liblas.hpp	(original)
+++ trunk/include/liblas/liblas.hpp	Sun Feb  8 20:47:34 2009
@@ -66,6 +66,7 @@
 {
     eLASVersion10 = 1 * 100000 + 0, ///< LAS Format 1.0
     eLASVersion11 = 1 * 100000 + 1, ///< LAS Format 1.1
+    eLASVersion12 = 1 * 100000 + 2, ///< LAS Format 1.2
     eLASVersion20 = 2 * 100000 + 0  ///< LAS Format 2.0
 };
 

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Sun Feb  8 20:47:34 2009
@@ -21,9 +21,11 @@
     detail/reader.cpp \
     detail/reader10.cpp \
     detail/reader11.cpp \
+    detail/reader12.cpp \
     detail/writer.cpp \
     detail/writer10.cpp \
     detail/writer11.cpp \
+	detail/writer12.cpp \
     detail/file.cpp
 
 #liblas_la_LIBADD = 	detail/liblasdetail.la

Modified: trunk/src/detail/reader.cpp
==============================================================================
--- trunk/src/detail/reader.cpp	(original)
+++ trunk/src/detail/reader.cpp	Sun Feb  8 20:47:34 2009
@@ -42,6 +42,7 @@
 #include <liblas/detail/reader.hpp>
 #include <liblas/detail/reader10.hpp>
 #include <liblas/detail/reader11.hpp>
+#include <liblas/detail/reader12.hpp>
 #include <liblas/lasheader.hpp>
 #include <liblas/laspoint.hpp>
 
@@ -84,6 +85,10 @@
     {
         return new v11::ReaderImpl(ifs);
     }
+    else if (1 == verMajor && 2 == verMinor)
+    {
+        return new v12::ReaderImpl(ifs);
+    }
     else if (2 == verMajor && 0 == verMinor )
     {
         // TODO: LAS 2.0 read/write support

Modified: trunk/src/detail/reader11.cpp
==============================================================================
--- trunk/src/detail/reader11.cpp	(original)
+++ trunk/src/detail/reader11.cpp	Sun Feb  8 20:47:34 2009
@@ -253,7 +253,7 @@
     // Read point data record format 1
 
     // TODO: Replace with compile-time assert
-    assert(28 == sizeof(record) + sizeof(time));
+    assert(LASHeader::ePointSize1 == sizeof(record) + sizeof(time));
 
     bool hasData = ReadNextPoint(record);
     if (hasData)

Copied: trunk/src/detail/reader12.cpp (from r1002, /trunk/src/detail/reader11.cpp)
==============================================================================
--- /trunk/src/detail/reader11.cpp	(original)
+++ trunk/src/detail/reader12.cpp	Sun Feb  8 20:47:34 2009
@@ -39,7 +39,7 @@
  * OF SUCH DAMAGE.
  ****************************************************************************/
 
-#include <liblas/detail/reader11.hpp>
+#include <liblas/detail/reader12.hpp>
 #include <liblas/detail/utility.hpp>
 #include <liblas/liblas.hpp>
 #include <liblas/lasheader.hpp>
@@ -60,7 +60,7 @@
 #include <cstdlib> // std::size_t
 #include <cassert>
 
-namespace liblas { namespace detail { namespace v11 {
+namespace liblas { namespace detail { namespace v12 {
 
 ReaderImpl::ReaderImpl(std::istream& ifs) : Base(), m_ifs(ifs)
 {
@@ -68,7 +68,7 @@
 
 std::size_t ReaderImpl::GetVersion() const
 {
-    return eLASVersion11;
+    return eLASVersion12;
 }
 
 bool ReaderImpl::ReadHeader(LASHeader& header)
@@ -139,7 +139,7 @@
     header.SetCreationYear(n2);
 
     // 14. Header Size
-    // NOTE: Size of the stanard header block must always be 227 bytes
+    // NOTE: Size of the standard header block must always be 227 bytes
     read_n(n2, m_ifs, sizeof(n2));
 
     // 15. Offset to data
@@ -157,12 +157,21 @@
 
     // 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
@@ -253,7 +262,7 @@
     // Read point data record format 1
 
     // TODO: Replace with compile-time assert
-    assert(28 == sizeof(record) + sizeof(time));
+    assert(LASHeader::ePointSize1 == sizeof(record) + sizeof(time));
 
     bool hasData = ReadNextPoint(record);
     if (hasData)

Copied: trunk/src/detail/writer12.cpp (from r1002, /trunk/src/detail/writer11.cpp)
==============================================================================
--- /trunk/src/detail/writer11.cpp	(original)
+++ trunk/src/detail/writer12.cpp	Sun Feb  8 20:47:34 2009
@@ -39,7 +39,7 @@
  * OF SUCH DAMAGE.
  ****************************************************************************/
 
-#include <liblas/detail/writer11.hpp>
+#include <liblas/detail/writer12.hpp>
 #include <liblas/detail/utility.hpp>
 #include <liblas/lasheader.hpp>
 #include <liblas/laspoint.hpp>
@@ -51,7 +51,7 @@
 #include <cstdlib> // std::size_t
 #include <cassert>
 
-namespace liblas { namespace detail { namespace v11 {
+namespace liblas { namespace detail { namespace v12 {
 
 WriterImpl::WriterImpl(std::ostream& ofs) :
     Base(), m_ofs(ofs), m_pointCount(0)
@@ -60,7 +60,7 @@
 
 std::size_t WriterImpl::GetVersion() const
 {
-    return eLASVersion11;
+    return eLASVersion12;
 }
 
 void WriterImpl::WriteHeader(LASHeader& header)
@@ -274,5 +274,5 @@
     return m_ofs;
 }
 
-}}} // namespace liblas::detail::v11
+}}} // namespace liblas::detail::v12
 

Modified: trunk/src/lasheader.cpp
==============================================================================
--- trunk/src/lasheader.cpp	(original)
+++ trunk/src/lasheader.cpp	Sun Feb  8 20:47:34 2009
@@ -377,18 +377,28 @@
 {
     if (ePointFormat0 == m_dataFormatId)
         return ePointFormat0;
-    else
+    else if (ePointFormat1 == m_dataFormatId)
         return ePointFormat1;
+    else if (ePointFormat2 == m_dataFormatId)
+        return ePointFormat2;
+    else
+        return ePointFormat3;
 }
 
 void LASHeader::SetDataFormatId(LASHeader::PointFormat v)
 {
-    m_dataFormatId = (ePointFormat0 == v ? 0 : 1);
+    m_dataFormatId = v;
 
     if (ePointFormat0 == m_dataFormatId)
         m_dataRecordLen = ePointSize0;
-    else
+    else if (ePointFormat1 == m_dataFormatId) 
         m_dataRecordLen = ePointSize1;
+    else if (ePointFormat2 == m_dataFormatId)
+        m_dataRecordLen = ePointSize2;
+    else if (ePointFormat3 == m_dataFormatId)
+        m_dataRecordLen = ePointSize3;
+    else
+        m_dataRecordLen = ePointSize3;
 }
 
 uint16_t LASHeader::GetDataRecordLength() const
@@ -401,11 +411,21 @@
         assert(ePointSize0 == m_dataRecordLen);
         return ePointSize0;
     }
-    else
+    if (ePointFormat1 == m_dataFormatId)
     {
         assert(ePointSize1 == m_dataRecordLen);
         return ePointSize1;
     }
+    if (ePointFormat2 == m_dataFormatId)
+    {
+        assert(ePointSize2 == m_dataRecordLen);
+        return ePointSize2;
+    }
+    else
+    {
+        assert(ePointSize3 == m_dataRecordLen);
+        return ePointSize3;
+    }
 }
 
 uint32_t LASHeader::GetPointRecordsCount() const

Modified: trunk/src/laspoint.cpp
==============================================================================
--- trunk/src/laspoint.cpp	(original)
+++ trunk/src/laspoint.cpp	Sun Feb  8 20:47:34 2009
@@ -56,7 +56,10 @@
     m_angleRank(0),
     m_userData(0),
     m_pointSourceId(0),
-    m_gpsTime(0)
+    m_gpsTime(0),
+    m_red(0),
+    m_green(0),
+    m_blue(0)
 {
     std::memset(m_coords, 0, sizeof(m_coords));
 }
@@ -68,7 +71,10 @@
     m_angleRank(other.m_angleRank),
     m_userData(other.m_userData),
     m_pointSourceId(other.m_pointSourceId),
-    m_gpsTime(other.m_gpsTime)
+    m_gpsTime(other.m_gpsTime),
+    m_red(other.m_red),
+    m_green(other.m_green),
+    m_blue(other.m_blue)
 {
     std::memcpy(m_coords, other.m_coords, sizeof(m_coords));
 }
@@ -87,6 +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;
     }
     return *this;
 }

Modified: trunk/src/lasreader.cpp
==============================================================================
--- trunk/src/lasreader.cpp	(original)
+++ trunk/src/lasreader.cpp	Sun Feb  8 20:47:34 2009
@@ -48,6 +48,7 @@
 #include <string>
 #include <cstring> // std::memset
 #include <cassert>
+#include <iostream>
 
 namespace liblas
 {
@@ -84,6 +85,8 @@
     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


More information about the Liblas-commits mailing list