[Liblas-commits] libpc: checkpoint - working on las reading

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Feb 15 20:25:56 EST 2011


details:   http://hg.liblas.orglibpc/rev/1bf406f41177
changeset: 61:1bf406f41177
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Tue Feb 15 13:54:49 2011 -0800
description:
checkpoint - working on las reading
Subject: libpc: checkpoint - las read/write

details:   http://hg.liblas.orglibpc/rev/9ec62d76b00f
changeset: 62:9ec62d76b00f
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Tue Feb 15 17:25:48 2011 -0800
description:
checkpoint - las read/write

diffstat:

 apps/pc2pc.cpp              |   26 +-
 include/libpc/Bounds.hpp    |    3 +-
 include/libpc/Dimension.hpp |   13 +-
 include/libpc/Header.hpp    |    4 +-
 include/libpc/LasHeader.hpp |   69 ++++-
 include/libpc/LasReader.hpp |    1 +
 include/libpc/LasSchema.hpp |  124 --------
 include/libpc/PointData.hpp |   37 +-
 include/libpc/Schema.hpp    |    9 +-
 include/libpc/Stage.hpp     |    5 +-
 include/libpc/Utils.hpp     |   39 ++-
 src/CMakeLists.txt          |    2 -
 src/ColorFilter.cpp         |    9 +-
 src/CropFilter.cpp          |    6 +-
 src/Dimension.cpp           |   35 +--
 src/FauxReader.cpp          |   18 +-
 src/Filter.cpp              |    5 +-
 src/Header.cpp              |   31 +-
 src/LasHeader.cpp           |  608 +++++++++++++++++++++++++++++++++++++++----
 src/LasReader.cpp           |  102 +++++++-
 src/LasSchema.cpp           |  298 ---------------------
 src/PointData.cpp           |   86 +----
 src/Schema.cpp              |   13 +
 src/Stage.cpp               |   17 +-
 24 files changed, 875 insertions(+), 685 deletions(-)

diffs (truncated from 2139 to 300 lines):

diff -r 241eaf8d3985 -r 9ec62d76b00f apps/pc2pc.cpp
--- a/apps/pc2pc.cpp	Tue Feb 15 12:16:37 2011 -0800
+++ b/apps/pc2pc.cpp	Tue Feb 15 17:25:48 2011 -0800
@@ -17,7 +17,6 @@
 #include "libpc/Color.hpp"
 #include "libpc/Dimension.hpp"
 #include "libpc/Schema.hpp"
-#include "libpc/LasSchema.hpp"
 #include "libpc/CropFilter.hpp"
 #include "libpc/ColorFilter.hpp"
 #include "libpc/MosaicFilter.hpp"
@@ -74,9 +73,25 @@
 
   LasReader reader(*ifs);
 
-  const LasHeader& header = ((const LasReader&)reader).getLasHeader();
+  const Header& header = reader.getHeader();
 
-  std::cout << header;
+  std::cout << (const LasHeader&)header;
+
+  boost::uint32_t numPoints = (boost::uint32_t)header.getNumPoints();
+  PointData pointData(header.getSchema(), numPoints);
+  reader.readPoints(pointData);
+
+//  std::cout << pointData;
+
+  std::ostream* ofs = Utils::Create("temp.las");
+
+  ((LasHeader&)header).write(*ofs);
+
+  ofs->flush();
+  delete ofs;
+
+//  Utils::Cleanup(ifs);
+//  Utils::Cleanup(ofs);
 
   return;
 }
@@ -107,11 +122,6 @@
         std::cout << dim << std::endl;
     }
 
-    {
-        LasSchema schema(LasSchema::ePointFormat0);
-        std::cout << schema;
-    }
-
     Color c;
 
     test1();
diff -r 241eaf8d3985 -r 9ec62d76b00f include/libpc/Bounds.hpp
--- a/include/libpc/Bounds.hpp	Tue Feb 15 12:16:37 2011 -0800
+++ b/include/libpc/Bounds.hpp	Tue Feb 15 17:25:48 2011 -0800
@@ -438,7 +438,8 @@
     for (size_t d = 0; d < bounds.size(); ++d)
     {
         const Range<T>& r = bounds.dims()[d];
-        ostr << "(" <<  r.minimum() << "," << r.maximum() << ")";
+        ostr << "[" <<  r.minimum() << ", " << r.maximum() << "]";
+        if (d!=bounds.size()-1) ostr << ", ";
     }
     return ostr;
 }
diff -r 241eaf8d3985 -r 9ec62d76b00f include/libpc/Dimension.hpp
--- a/include/libpc/Dimension.hpp	Tue Feb 15 12:16:37 2011 -0800
+++ b/include/libpc/Dimension.hpp	Tue Feb 15 17:25:48 2011 -0800
@@ -76,13 +76,11 @@
         int64_t,
         uint64_t,
         float_t,       // 32 bits
-        double_t,      // 64 bits
-        bits_t,        // a bitfield of a given size (no integral representation is assumed)
+        double_t      // 64 bits
     };
 
 public:
-    // size_in_bits is only meaningful if type==bits_t
-    Dimension(std::string const& name, DataType type, std::size_t size_in_bits=0);
+    Dimension(std::string const& name, DataType type);
     Dimension& operator=(Dimension const& rhs);
     Dimension(Dimension const& other);
 
@@ -107,12 +105,6 @@
     static bool getDataTypeIsSigned(DataType);
     static bool getDataTypeIsInteger(DataType);
 
-    /// bits, total logical size of point record
-    inline std::size_t getBitSize() const
-    {
-        return m_bitSize;
-    }
-
     /// bytes, physical/serialisation size of record
     // for bitfields, this will be rounded up to the next largest byte
     std::size_t getByteSize() const
@@ -237,7 +229,6 @@
 private:
     DataType m_dataType;
     std::string m_name;
-    std::size_t m_bitSize;
     std::size_t m_byteSize;
     std::size_t m_byteOffset;
     std::string m_description;
diff -r 241eaf8d3985 -r 9ec62d76b00f include/libpc/Header.hpp
--- a/include/libpc/Header.hpp	Tue Feb 15 12:16:37 2011 -0800
+++ b/include/libpc/Header.hpp	Tue Feb 15 17:25:48 2011 -0800
@@ -54,8 +54,6 @@
     Header(const Header&);
     virtual ~Header();
 
-    Header& operator=(const Header&);
-
     const Schema& getSchema() const;
     Schema& getSchema();
     void setSchema(const Schema&);
@@ -78,6 +76,8 @@
     Bounds<double> m_bounds;
     SpatialReference m_spatialReference;
     Metadata::Array m_metadataArray;
+
+    Header& operator=(const Header&); // nope
 };
 
 
diff -r 241eaf8d3985 -r 9ec62d76b00f include/libpc/LasHeader.hpp
--- a/include/libpc/LasHeader.hpp	Tue Feb 15 12:16:37 2011 -0800
+++ b/include/libpc/LasHeader.hpp	Tue Feb 15 17:25:48 2011 -0800
@@ -50,7 +50,6 @@
 #include <boost/uuid/uuid.hpp>
 
 #include "libpc/Header.hpp"
-#include "libpc/LasSchema.hpp"
 
 namespace libpc
 {
@@ -60,6 +59,47 @@
 public:
     typedef boost::uuids::uuid uuid;
 
+    /// Versions of point record format.
+    enum PointFormatId
+    {
+        ePointFormat0 = 0,  ///< Point Data Format \e 0
+        ePointFormat1 = 1,  ///< Point Data Format \e 1    
+        ePointFormat2 = 2,  ///< Point Data Format \e 2
+        ePointFormat3 = 3,  ///< Point Data Format \e 3
+        ePointFormat4 = 4,  ///< Point Data Format \e 3
+        ePointFormat5 = 5,  ///< Point Data Format \e 3
+        ePointFormatUnknown = -99 ///< Point Data Format is unknown
+    };
+
+    /// Number of bytes of point record storage in particular format.
+    enum PointSize
+    {
+        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 = 34  ///< Size of point record in data format \e 3
+    };
+
+    /// Version numbers of the ASPRS LAS Specification.
+    /// Numerical representation of versions is calculated according to 
+    /// following formula: <em>major * 100000 + minor</em>
+    enum LASVersion
+    {
+        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
+    };
+
+    /// Range of allowed ASPRS LAS file format versions.
+    enum FormatVersion
+    {
+        eVersionMajorMin = 1, ///< Minimum of major component
+        eVersionMajorMax = 1, ///< Maximum of major component
+        eVersionMinorMin = 0, ///< Minimum of minor component
+        eVersionMinorMax = 3  ///< Maximum of minor component
+    };
+
 public:
     /// The default constructed header is configured according to the ASPRS
     /// LAS 1.2 Specification, point data format set to 0.
@@ -204,10 +244,10 @@
     void SetRecordsCount(boost::uint32_t v);
     
     /// Get identifier of point data (record) format.
-    LasSchema::PointFormatName GetDataFormatId() const;
+    PointFormatId getDataFormatId() const;
 
     /// Set identifier of point data (record) format.
-    void SetDataFormatId(LasSchema::PointFormatName v);
+    void setDataFormatId(PointFormatId v);
 
     /// The length in bytes of each point.  All points in the file are 
     /// considered to be fixed in size, and the PointFormatName is used 
@@ -315,7 +355,7 @@
     
 
     void read(std::istream&);
-    void write(std::ostream&) const;
+    void write(std::ostream&);
 
 private:
     typedef Vector<double> PointScales;
@@ -342,9 +382,14 @@
     void ReadVLRs(std::istream& ifs);
     void Validate(std::istream& ifs);
 
-    const LasSchema& getLasSchema() const;
-    LasSchema& getLasSchema();
-    void setLasSchema(const LasSchema&);
+    static void update_required_dimensions(PointFormatId data_format_id, Schema&);
+    static void add_record0_dimensions(Schema& schema);
+    static void add_time(Schema& schema);
+    static void add_color(Schema& schema);
+    
+    void WriteLAS10PadSignature(std::ostream& ostream);
+    boost::int32_t GetRequiredHeaderSize(std::ostream& ostream) const;
+    void WriteVLRs(std::ostream& ostream);
 
     //
     // Private data members
@@ -366,14 +411,12 @@
     RecordsByReturnArray m_pointRecordsByReturn;
     PointScales m_scales;
     PointOffsets m_offsets;
-//    Bounds<double> m_extent;
-//    std::vector<VariableRecord> m_vlrs;
-//    SpatialReference m_srs;
-//    Schema m_schema;
     bool m_isCompressed;
 
-    LasHeader& operator=(const LasHeader&); // not implemented
-    LasHeader(const LasHeader&); // not implemented
+    PointFormatId m_data_format_id;
+
+    LasHeader& operator=(const LasHeader&); // nope
+    LasHeader(const LasHeader&); // nope
 };
 
 LIBPC_DLL std::ostream& operator<<(std::ostream& ostr, const LasHeader&);
diff -r 241eaf8d3985 -r 9ec62d76b00f include/libpc/LasReader.hpp
--- a/include/libpc/LasReader.hpp	Tue Feb 15 12:16:37 2011 -0800
+++ b/include/libpc/LasReader.hpp	Tue Feb 15 17:25:48 2011 -0800
@@ -61,6 +61,7 @@
 
 protected:
     LasHeader& getLasHeader();
+    void setLasHeader(const LasHeader&);
 
     std::istream& m_istream;
 
diff -r 241eaf8d3985 -r 9ec62d76b00f include/libpc/LasSchema.hpp
--- a/include/libpc/LasSchema.hpp	Tue Feb 15 12:16:37 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-/******************************************************************************
- * $Id$
- *
- * Project:  libLAS - http://liblas.org - A BSD library for LAS format data.
- * Purpose:  LAS Schema implementation for C++ libLAS
- * Author:   Howard Butler, hobu.inc at gmail.com
- *
- ******************************************************************************
- * Copyright (c) 2010, Howard Butler
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following
- * conditions are met:
- *
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in
- *       the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of the Martin Isenburg or Iowa Department
- *       of Natural Resources nor the names of its contributors may be
- *       used to endorse or promote products derived from this software
- *       without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- ****************************************************************************/
-
-#ifndef LIBPC_LASSCHEMA_HPP_INCLUDED


More information about the Liblas-commits mailing list