[Liblas-commits] hg: use references of PointFormat instead of copying

liblas-commits at liblas.org liblas-commits at liblas.org
Sun Mar 21 23:02:25 EDT 2010


changeset 0a681a3a232a in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=0a681a3a232a
summary: use references of PointFormat instead of copying

diffstat:

 cmake/modules/BuildOSGeo4W.cmake       |  15 ---------------
 include/liblas/detail/reader/point.hpp |   1 +
 include/liblas/detail/writer/point.hpp |   2 ++
 src/detail/reader/point.cpp            |  16 ++++++++--------
 src/detail/writer/point.cpp            |   7 ++++---
 5 files changed, 15 insertions(+), 26 deletions(-)

diffs (153 lines):

diff -r 9d2e7ae6e4bf -r 0a681a3a232a cmake/modules/BuildOSGeo4W.cmake
--- a/cmake/modules/BuildOSGeo4W.cmake	Sun Mar 21 13:31:10 2010 -0600
+++ b/cmake/modules/BuildOSGeo4W.cmake	Sun Mar 21 21:56:56 2010 -0500
@@ -2,21 +2,6 @@
 #
 # OSGeo4W packaging
 #
-# On success, the macro sets the following variables:
-# GEOTIFF_FOUND       = if the library found
-# GEOTIFF_LIBRARIES   = full path to the library
-# GEOTIFF_INCLUDE_DIR = where to find the library headers also defined,
-#                       but not for general use are
-# GEOTIFF_LIBRARY     = where to find the PROJ.4 library.
-# GEOTIFF_VERSION     = version of library which was found, e.g. "1.2.5"
-#
-# Copyright (c) 2009 Mateusz Loskot <mateusz at loskot.net>
-#
-# Module source: http://github.com/mloskot/workshop/tree/master/cmake/
-#
-# Redistribution and use is allowed according to the terms of the BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-#
 ###############################################################################
 
 if(WIN32)
diff -r 9d2e7ae6e4bf -r 0a681a3a232a include/liblas/detail/reader/point.hpp
--- a/include/liblas/detail/reader/point.hpp	Sun Mar 21 13:31:10 2010 -0600
+++ b/include/liblas/detail/reader/point.hpp	Sun Mar 21 21:56:56 2010 -0500
@@ -93,6 +93,7 @@
     const liblas::Header& m_header;
     liblas::Point m_point;
     OGRCoordinateTransformationH m_transform;
+    const liblas::PointFormat& m_format;
     
     
     void project();
diff -r 9d2e7ae6e4bf -r 0a681a3a232a include/liblas/detail/writer/point.hpp
--- a/include/liblas/detail/writer/point.hpp	Sun Mar 21 13:31:10 2010 -0600
+++ b/include/liblas/detail/writer/point.hpp	Sun Mar 21 21:56:56 2010 -0500
@@ -46,6 +46,7 @@
 #include <liblas/detail/fwd.hpp>
 
 #include <liblas/laspoint.hpp>
+#include <liblas/lasformat.hpp>
 
 #include <liblas/detail/utility.hpp>
 
@@ -99,6 +100,7 @@
     OGRCoordinateTransformationH m_transform;
     
     PointRecord m_record;
+    const liblas::PointFormat& m_format;
     
     void project();
     void setup();
diff -r 9d2e7ae6e4bf -r 0a681a3a232a src/detail/reader/point.cpp
--- a/src/detail/reader/point.cpp	Sun Mar 21 13:31:10 2010 -0600
+++ b/src/detail/reader/point.cpp	Sun Mar 21 21:56:56 2010 -0500
@@ -54,7 +54,7 @@
 }
 
 Point::Point(std::istream& ifs, const liblas::Header& header) :
-    m_ifs(ifs), m_header(header), m_point(liblas::Point()), m_transform(0)
+    m_ifs(ifs), m_header(header), m_point(liblas::Point()), m_transform(0), m_format(header.GetPointFormat())
 {
     setup();
 }
@@ -62,7 +62,7 @@
 Point::Point(   std::istream& ifs, 
                 const liblas::Header& header, 
                 OGRCoordinateTransformationH transform) :
-    m_ifs(ifs), m_header(header), m_point(liblas::Point()), m_transform(transform)
+    m_ifs(ifs), m_header(header), m_point(liblas::Point()), m_transform(transform), m_format(header.GetPointFormat())
 {
     setup();
 }
@@ -106,14 +106,14 @@
     // Reader::FillPoint(record, m_point, m_header);
     m_point.SetCoordinates(m_header, m_point.GetX(), m_point.GetY(), m_point.GetZ());
 
-    if (m_header.GetPointFormat().HasTime()) 
+    if (m_format.HasTime()) 
     {
 
         detail::read_n(gpst, m_ifs, sizeof(double));
         m_point.SetTime(gpst);
         bytesread += sizeof(double);
         
-        if (m_header.GetPointFormat().HasColor()) 
+        if (m_format.HasColor()) 
         {
             detail::read_n(red, m_ifs, sizeof(uint16_t));
             detail::read_n(green, m_ifs, sizeof(uint16_t));
@@ -125,7 +125,7 @@
             bytesread += 3 * sizeof(uint16_t);
         }
     } else {
-        if (m_header.GetPointFormat().HasColor()) 
+        if (m_format.HasColor()) 
         {
             detail::read_n(red, m_ifs, sizeof(uint16_t));
             detail::read_n(green, m_ifs, sizeof(uint16_t));
@@ -138,16 +138,16 @@
         }        
     }
 
-    if (bytesread != m_header.GetPointFormat().GetByteSize()) {
+    if (bytesread != m_format.GetByteSize()) {
         std::ostringstream msg; 
         msg <<  "The number of bytes that were read ("<< bytesread <<") does not " 
                 "match the number of bytes the point's format "
                 "says it should have (" << 
-                m_header.GetPointFormat().GetByteSize() << ")";
+                m_format.GetByteSize() << ")";
         throw std::runtime_error(msg.str());
         
     }
-    if (m_header.GetPointFormat().GetByteSize() != m_header.GetDataRecordLength())
+    if (m_format.GetByteSize() != m_header.GetDataRecordLength())
     {
         std::size_t bytesleft = m_header.GetDataRecordLength() - bytesread;
 
diff -r 9d2e7ae6e4bf -r 0a681a3a232a src/detail/writer/point.cpp
--- a/src/detail/writer/point.cpp	Sun Mar 21 13:31:10 2010 -0600
+++ b/src/detail/writer/point.cpp	Sun Mar 21 21:56:56 2010 -0500
@@ -62,7 +62,8 @@
     m_ofs(ofs), 
     m_header(header), 
     m_point(liblas::Point()), 
-    m_transform(0)
+    m_transform(0),
+    m_format(header.GetPointFormat())
 {
     setup();
 }
@@ -71,7 +72,7 @@
                 liblas::uint32_t& count,
                 const liblas::Header& header, 
                 OGRCoordinateTransformationH transform) : Base(ofs, count),
-    m_ofs(ofs), m_header(header), m_point(liblas::Point()), m_transform(transform)
+    m_ofs(ofs), m_header(header), m_point(liblas::Point()), m_transform(transform), m_format(header.GetPointFormat())
 
 {
     setup();
@@ -141,7 +142,7 @@
 
     // write in our extra data that the user set on the 
     // point up to the header's specified DataRecordLength
-    if (m_header.GetPointFormat().GetByteSize() != m_header.GetDataRecordLength()) {
+    if (m_format.GetByteSize() != m_header.GetDataRecordLength()) {
 
         std::vector<uint8_t> const& data = point.GetExtraData();
         std::streamsize const size = static_cast<std::streamsize>(m_header.GetDataRecordLength() - data.size());


More information about the Liblas-commits mailing list