[Liblas-commits] libpc: checkpoint: renamed Layout to Schema, adding las header r...

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Feb 15 15:16:43 EST 2011


details:   http://hg.liblas.orglibpc/rev/31f69d74f46f
changeset: 58:31f69d74f46f
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Tue Feb 15 10:30:59 2011 -0800
description:
checkpoint: renamed Layout to Schema, adding las header reading ability
Subject: libpc: las header reader coming online

details:   http://hg.liblas.orglibpc/rev/dfd58bd6ddf4
changeset: 59:dfd58bd6ddf4
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Tue Feb 15 11:58:18 2011 -0800
description:
las header reader coming online
Subject: libpc: tweaks

details:   http://hg.liblas.orglibpc/rev/241eaf8d3985
changeset: 60:241eaf8d3985
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Tue Feb 15 12:16:37 2011 -0800
description:
tweaks

diffstat:

 apps/pc2pc.cpp              |    19 +
 include/libpc/Bounds.hpp    |     8 +-
 include/libpc/Header.hpp    |    12 +-
 include/libpc/LasHeader.hpp |   383 ++++++++++++++
 include/libpc/LasReader.hpp |    74 ++
 include/libpc/LasSchema.hpp |    33 +
 include/libpc/LasWriter.hpp |    73 ++
 include/libpc/PointData.hpp |    14 +-
 include/libpc/Reader.hpp    |     2 +-
 include/libpc/Stage.hpp     |     5 +-
 include/libpc/Utils.hpp     |    47 +
 include/libpc/Vector.hpp    |    40 +-
 src/CMakeLists.txt          |     9 +-
 src/ColorFilter.cpp         |    18 +-
 src/CropFilter.cpp          |     8 +-
 src/FauxReader.cpp          |    20 +-
 src/Header.cpp              |    26 +-
 src/LasHeader.cpp           |  1165 +++++++++++++++++++++++++++++++++++++++++++
 src/LasReader.cpp           |    92 +++
 src/LasSchema.cpp           |    24 +
 src/LasWriter.cpp           |    65 ++
 src/MosaicFilter.cpp        |    10 +-
 src/PointData.cpp           |    22 +-
 src/Reader.cpp              |     2 +-
 src/Schema.cpp              |     4 +-
 src/Stage.cpp               |     6 +
 src/Writer.cpp              |     2 +-
 27 files changed, 2106 insertions(+), 77 deletions(-)

diffs (truncated from 2686 to 300 lines):

diff -r 931718485dda -r 241eaf8d3985 apps/pc2pc.cpp
--- a/apps/pc2pc.cpp	Mon Feb 14 21:14:06 2011 -0800
+++ b/apps/pc2pc.cpp	Tue Feb 15 12:16:37 2011 -0800
@@ -23,6 +23,8 @@
 #include "libpc/MosaicFilter.hpp"
 #include "libpc/FauxReader.hpp"
 #include "libpc/FauxWriter.hpp"
+#include "libpc/LasReader.hpp"
+#include "libpc/LasHeader.hpp"
 
 using namespace libpc;
 
@@ -65,8 +67,25 @@
 }
 
 
+
+static void test3()
+{
+  std::istream* ifs = Utils::Open("test/data/1.2-with-color.las");
+
+  LasReader reader(*ifs);
+
+  const LasHeader& header = ((const LasReader&)reader).getLasHeader();
+
+  std::cout << header;
+
+  return;
+}
+
+
 int main(int, char* [])
 {
+    test3();
+
     {
         Bounds<double> bounds(1,2,3,4,5,6);
         std::cout << bounds << std::endl;
diff -r 931718485dda -r 241eaf8d3985 include/libpc/Bounds.hpp
--- a/include/libpc/Bounds.hpp	Mon Feb 14 21:14:06 2011 -0800
+++ b/include/libpc/Bounds.hpp	Tue Feb 15 12:16:37 2011 -0800
@@ -136,8 +136,8 @@
     
         for (std::size_t i=0; i<minimum.size(); i++)
         {
-            m_ranges[i].setMinimum(minimum.vN(i));
-            m_ranges[i].setMaximum(maximum.vN(i));
+            m_ranges[i].setMinimum(minimum.getn(i));
+            m_ranges[i].setMaximum(maximum.getn(i));
         }    
 
     #ifdef DEBUG
@@ -294,7 +294,7 @@
         for (size_type i = 0; i < size(); i++)
         {
             // As soon as it is not contains, we're false
-            if (! m_ranges[i].contains(point.vN(i)) )
+            if (! m_ranges[i].contains(point.getn(i)) )
                 return false;
         }
         return true;
@@ -376,7 +376,7 @@
         assert(point.size() == size());
         for (size_type i = 0; i < size(); ++i)
         {
-            m_ranges[i].grow(point.vN(i));
+            m_ranges[i].grow(point.getn(i));
         }
     }
 
diff -r 931718485dda -r 241eaf8d3985 include/libpc/Header.hpp
--- a/include/libpc/Header.hpp	Mon Feb 14 21:14:06 2011 -0800
+++ b/include/libpc/Header.hpp	Tue Feb 15 12:16:37 2011 -0800
@@ -52,11 +52,13 @@
 public:
     Header();
     Header(const Header&);
+    virtual ~Header();
+
     Header& operator=(const Header&);
 
-    const Schema& getLayout() const;
-    Schema& getLayout();
-    void setLayout(const Schema&);
+    const Schema& getSchema() const;
+    Schema& getSchema();
+    void setSchema(const Schema&);
 
     boost::uint64_t getNumPoints() const;
     void setNumPoints(boost::uint64_t);
@@ -71,7 +73,7 @@
     Metadata::Array& getMetadata();
 
 private:
-    Schema m_pointLayout;
+    Schema m_schema;
     boost::uint64_t m_numPoints;
     Bounds<double> m_bounds;
     SpatialReference m_spatialReference;
@@ -79,7 +81,7 @@
 };
 
 
-std::ostream& operator<<(std::ostream& ostr, const Header&);
+LIBPC_DLL std::ostream& operator<<(std::ostream& ostr, const Header&);
 
 
 } // namespace libpc
diff -r 931718485dda -r 241eaf8d3985 include/libpc/LasHeader.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/LasHeader.hpp	Tue Feb 15 12:16:37 2011 -0800
@@ -0,0 +1,383 @@
+/******************************************************************************
+ * $Id$
+ *
+ * Project:  libLAS - http://liblas.org - A BSD library for LAS format data.
+ * Purpose:  LAS header class 
+ * Author:   Mateusz Loskot, mateusz at loskot.net
+ *
+ ******************************************************************************
+ * Copyright (c) 2008, Mateusz Loskot
+ * Copyright (c) 2008, Phil Vachon
+ *
+ * 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 INCLUDED_LASHEADER_HPP
+#define INCLUDED_LASHEADER_HPP
+
+#include <iostream>
+#include <string>
+
+#include <boost/cstdint.hpp>
+#include <boost/uuid/uuid.hpp>
+
+#include "libpc/Header.hpp"
+#include "libpc/LasSchema.hpp"
+
+namespace libpc
+{
+
+class LIBPC_DLL LasHeader : public Header
+{
+public:
+    typedef boost::uuids::uuid uuid;
+
+public:
+    /// The default constructed header is configured according to the ASPRS
+    /// LAS 1.2 Specification, point data format set to 0.
+    /// Other fields filled with 0.
+    LasHeader();
+
+    /// Official signature of ASPRS LAS file format, always \b "LASF".
+    static char const* const FileSignature;
+
+    /// Default system identifier used by libLAS, always \b "libLAS".
+    static char const* const SystemIdentifier;
+
+    /// Default software identifier used by libLAS, always \b "libLAS X.Y".
+    static char const* const SoftwareIdentifier;
+
+    /// Array of 5 elements - numbers of points recorded by each return.
+    /// \todo TODO: Consider replacing with {boost|std::tr1}::array<T, 5> --mloskot
+    typedef std::vector<boost::uint32_t> RecordsByReturnArray;
+
+    /// Get ASPRS LAS file signature.
+    /// \return 4-characters long string - \b "LASF".
+    std::string GetFileSignature() const;
+
+    /// Set ASPRS LAS file signature.
+    /// The only value allowed as file signature is \b "LASF",
+    /// defined as FileSignature constant.
+    /// \exception std::invalid_argument - if invalid signature given.
+    /// \param v - string contains file signature, at least 4-bytes long
+    /// with "LASF" as first four bytes.
+    void SetFileSignature(std::string const& v);
+
+    /// Get file source identifier.
+    /// \exception No throw
+    boost::uint16_t GetFileSourceId() const;
+
+    /// Set file source identifier.
+    /// \param v - should be set to a value between 1 and 65535.
+    /// \exception No throw
+    ///
+    /// \todo TODO: Should we warn or throw about type overflow when user passes 65535 + 1 = 0
+    void SetFileSourceId(boost::uint16_t v);
+
+    /// Get value field reserved by the ASPRS LAS Specification.
+    /// \note This field is always filled with 0.
+    ///
+    /// \todo TODO: Should we warn or throw about type overflow when user passes 65535 + 1 = 0
+    boost::uint16_t GetReserved() const;
+
+    /// Set reserved value for the header identifier.
+    /// \param v - should be set to a value between 1 and 65535.
+    /// \exception No throw
+    void SetReserved(boost::uint16_t v);
+
+    /// Get project identifier.
+    /// \return Global Unique Identifier as an instance of liblas::guid class.
+    uuid GetProjectId() const;
+
+    /// Set project identifier.
+    void SetProjectId(uuid const& v);
+
+    /// Get major component of version of LAS format.
+    /// \return Always 1 is returned as the only valid value.
+    boost::uint8_t GetVersionMajor() const;
+
+    /// Set major component of version of LAS format.
+    /// \exception std::out_of_range - invalid value given.
+    /// \param v - value between eVersionMajorMin and eVersionMajorMax.
+    void SetVersionMajor(boost::uint8_t v);
+
+    /// Get minor component of version of LAS format.
+    /// \return Valid values are 0, 1, 2, 3.
+    boost::uint8_t GetVersionMinor() const;
+
+    /// Set minor component of version of LAS format.
+    /// \exception std::out_of_range - invalid value given.
+    /// \param v - value between eVersionMinorMin and eVersionMinorMax.
+    void SetVersionMinor(boost::uint8_t v);
+
+    /// Get system identifier.
+    /// Default value is \b "libLAS" specified as the SystemIdentifier constant.
+    /// \param pad - if true the returned string is padded right with spaces and
+    /// its length is 32 bytes, if false (default) no padding occurs and
+    /// length of the returned string is <= 32 bytes.
+    /// \return value of system identifier field.
+    std::string GetSystemId(bool pad = false) const;
+
+    /// Set system identifier.
+    /// \exception std::invalid_argument - if identifier longer than 32 bytes.
+    /// \param v - system identifiers string.
+    void SetSystemId(std::string const& v);
+
+    /// Get software identifier.
+    /// Default value is \b "libLAS 1.0", specified as the SoftwareIdentifier constant.
+    /// \param pad - if true the returned string is padded right with spaces and its length is 32 bytes,
+    /// if false (default) no padding occurs and length of the returned string is <= 32 bytes.
+    /// \return value of generating software identifier field.
+    std::string GetSoftwareId(bool pad = false) const;
+
+    /// Set software identifier.
+    /// \exception std::invalid_argument - if identifier is longer than 32 bytes.
+    /// \param v - software identifiers string.
+    void SetSoftwareId(std::string const& v);
+
+    /// Get day of year of file creation date.
+    /// \todo TODO: Use full date structure instead of Julian date number.
+    boost::uint16_t GetCreationDOY() const;
+
+    /// Set day of year of file creation date.
+    /// \exception std::out_of_range - given value is higher than number 366.
+    /// \todo TODO: Use full date structure instead of Julian date number.
+    void SetCreationDOY(boost::uint16_t v);
+
+    /// Set year of file creation date.
+    /// \todo TODO: Remove if full date structure is used.
+    boost::uint16_t GetCreationYear() const;
+
+    /// Get year of file creation date.
+    /// \exception std::out_of_range - given value is higher than number 9999.
+    /// \todo TODO: Remove if full date structure is used.
+    void SetCreationYear(boost::uint16_t v);
+
+    /// Get number of bytes of generic verion of public header block storage.
+    /// Standard version of the public header block is 227 bytes long.
+    boost::uint16_t GetHeaderSize() const;
+
+    /// Sets the header size.  Note that this is not the same as the offset to 


More information about the Liblas-commits mailing list