[Liblas-commits] hg-main-tree: start of VLR work

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Apr 21 15:06:42 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/7115cf9d8b9b
changeset: 610:7115cf9d8b9b
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Apr 21 12:06:35 2011 -0700
description:
start of VLR work

diffstat:

 include/libpc/Metadata.hpp                         |   78 -------------
 include/libpc/MetadataRecord.hpp                   |   73 ++++++++++++
 include/libpc/Stage.hpp                            |   10 +-
 include/libpc/Utils.hpp                            |    8 +
 include/libpc/drivers/las/Header.hpp               |    6 +
 include/libpc/drivers/las/Reader.hpp               |    5 +
 include/libpc/drivers/las/VariableLengthRecord.hpp |   76 +++++++++++++
 src/CMakeLists.txt                                 |    6 +-
 src/Metadata.cpp                                   |  119 ---------------------
 src/MetadataRecord.cpp                             |  113 +++++++++++++++++++
 src/Stage.cpp                                      |   24 +++-
 src/drivers/las/Header.cpp                         |   13 ++
 src/drivers/las/LasHeaderReader.cpp                |   99 ++++++++++-------
 src/drivers/las/LasHeaderReader.hpp                |    8 +-
 src/drivers/las/Reader.cpp                         |   18 +++
 src/drivers/las/VariableLengthRecord.cpp           |  108 +++++++++++++++++++
 test/unit/LasReaderTest.cpp                        |   10 +
 17 files changed, 521 insertions(+), 253 deletions(-)

diffs (truncated from 1039 to 300 lines):

diff -r 081987228371 -r 7115cf9d8b9b include/libpc/Metadata.hpp
--- a/include/libpc/Metadata.hpp	Thu Apr 21 11:45:58 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/******************************************************************************
-* Copyright (c) 2011, Michael P. Gerlek (mpg at flaxen.com)
-*
-* 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 Hobu, Inc. or Flaxen Geo Consulting 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_METADATA_HPP
-#define INCLUDED_METADATA_HPP
-
-#include <libpc/libpc.hpp>
-
-#include <vector>
-
-namespace libpc
-{
-
-// this needs work, but the idea is this will be something that specific file formats
-// could derive from
-class LIBPC_DLL Metadata
-{
-public:
-    typedef std::vector<Metadata> Array;
-
-public:
-    // makes a local copy of the buffer
-    Metadata(const boost::uint8_t* bytes, std::size_t len);
-
-    Metadata(const Metadata&);
-
-    virtual ~Metadata();
-
-    Metadata& operator=(Metadata const& rhs);
-
-    bool operator==(Metadata const& rhs) const;
-
-    const boost::uint8_t* getBytes() const;
-    std::size_t getLength() const;
-
-private:
-    boost::uint8_t* m_bytes;
-    std::size_t m_length;
-};
-
-
-std::ostream& operator<<(std::ostream& ostr, const Metadata& srs);
-
-
-} // namespace libpc
-
-#endif
diff -r 081987228371 -r 7115cf9d8b9b include/libpc/MetadataRecord.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/MetadataRecord.hpp	Thu Apr 21 12:06:35 2011 -0700
@@ -0,0 +1,73 @@
+/******************************************************************************
+* Copyright (c) 2011, Michael P. Gerlek (mpg at flaxen.com)
+*
+* 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 Hobu, Inc. or Flaxen Geo Consulting 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_METADATARECORD_HPP
+#define INCLUDED_METADATARECORD_HPP
+
+#include <libpc/libpc.hpp>
+
+#include <boost/shared_array.hpp>
+
+namespace libpc
+{
+
+class LIBPC_DLL MetadataRecord
+{
+public:
+    // makes a local copy of the buffer, which is a shared ptr among by all copes of the metadata record
+    MetadataRecord(const boost::uint8_t* bytes, std::size_t len);
+
+    MetadataRecord(const MetadataRecord&);
+
+    virtual ~MetadataRecord();
+
+    MetadataRecord& operator=(MetadataRecord const& rhs);
+
+    bool operator==(MetadataRecord const& rhs) const;
+
+    const boost::shared_array<boost::uint8_t> getBytes() const;
+    std::size_t getLength() const;
+
+private:
+    boost::shared_array<boost::uint8_t> m_bytes;
+    std::size_t m_length;
+};
+
+
+std::ostream& operator<<(std::ostream& ostr, const MetadataRecord& srs);
+
+
+} // namespace libpc
+
+#endif
diff -r 081987228371 -r 7115cf9d8b9b include/libpc/Stage.hpp
--- a/include/libpc/Stage.hpp	Thu Apr 21 11:45:58 2011 -0700
+++ b/include/libpc/Stage.hpp	Thu Apr 21 12:06:35 2011 -0700
@@ -42,7 +42,7 @@
 #include <libpc/Schema.hpp>
 #include <libpc/Bounds.hpp>
 #include <libpc/SpatialReference.hpp>
-#include <libpc/Metadata.hpp>
+#include <libpc/MetadataRecord.hpp>
 
 namespace libpc
 {
@@ -70,7 +70,9 @@
     PointCountType getPointCountType() const;
     const Bounds<double>& getBounds() const;
     const SpatialReference& getSpatialReference() const;
-    const Metadata::Array& getMetadata() const;
+    
+    virtual int getMetadataRecordCount() const;
+    virtual const MetadataRecord& getMetadataRecord(int index) const;
 
     virtual bool supportsIterator (StageIteratorType) const = 0;
 
@@ -88,7 +90,8 @@
     void setPointCountType(PointCountType);
     void setBounds(const Bounds<double>&);
     void setSpatialReference(const SpatialReference&);
-    Metadata::Array& getMetadata();
+    
+    virtual MetadataRecord& getMetadataRecordRef(int index);
 
     // convenience function, for doing a "copy ctor" on all the core props
     // (used by the Filter stage, for example)
@@ -100,7 +103,6 @@
     PointCountType m_pointCountType;
     Bounds<double> m_bounds;
     SpatialReference m_spatialReference;
-    Metadata::Array m_metadataArray;
 
     Stage& operator=(const Stage&); // not implemented
     Stage(const Stage&); // not implemented
diff -r 081987228371 -r 7115cf9d8b9b include/libpc/Utils.hpp
--- a/include/libpc/Utils.hpp	Thu Apr 21 11:45:58 2011 -0700
+++ b/include/libpc/Utils.hpp	Thu Apr 21 12:06:35 2011 -0700
@@ -106,6 +106,14 @@
         return tmp;
     }
 
+    template<class T>
+    static inline void read_array_field(boost::uint8_t*& src, T* dest, std::size_t count)
+    {
+        memcpy((boost::uint8_t*)dest, (boost::uint8_t*)(T*)src, sizeof(T)*count);
+        src += sizeof(T) * count;
+        return;
+    }
+
     template <typename T>
     static inline void read_n(T& dest, std::istream& src, std::streamsize const& num)
     {
diff -r 081987228371 -r 7115cf9d8b9b include/libpc/drivers/las/Header.hpp
--- a/include/libpc/drivers/las/Header.hpp	Thu Apr 21 11:45:58 2011 -0700
+++ b/include/libpc/drivers/las/Header.hpp	Thu Apr 21 12:06:35 2011 -0700
@@ -54,6 +54,7 @@
 #include <libpc/Vector.hpp>
 #include <libpc/Bounds.hpp>
 #include <libpc/drivers/las/Support.hpp>
+#include <libpc/drivers/las/VariableLengthRecord.hpp>
 
 namespace libpc { namespace drivers { namespace las {
 
@@ -334,6 +335,9 @@
     /// Sets whether or not the points are compressed.
     void SetCompressed(bool b);
 
+    const std::vector<VariableLengthRecord>& getVLRs() const;
+    std::vector<VariableLengthRecord>& getVLRsRef();
+
     //void to_rst(std::ostream& os) const;
     //void to_xml(std::ostream& os) const;
     //void to_json(std::ostream& os) const;
@@ -386,6 +390,8 @@
 
     Bounds<double> m_bounds;
 
+    std::vector<VariableLengthRecord> m_vlrs;
+
     LasHeader& operator=(const LasHeader&); // nope
     LasHeader(const LasHeader&); // nope
 };
diff -r 081987228371 -r 7115cf9d8b9b include/libpc/drivers/las/Reader.hpp
--- a/include/libpc/drivers/las/Reader.hpp	Thu Apr 21 11:45:58 2011 -0700
+++ b/include/libpc/drivers/las/Reader.hpp	Thu Apr 21 12:06:35 2011 -0700
@@ -73,6 +73,9 @@
     // this is called by the stage's iterator
     boost::uint32_t processBuffer(PointBuffer& PointBuffer, std::istream& stream, boost::uint64_t numPointsLeft) const;
 
+    int getMetadataRecordCount() const;
+    const MetadataRecord& getMetadataRecord(int index) const;
+
     PointFormat getPointFormat() const;
     boost::uint8_t getVersionMajor() const;
     boost::uint8_t getVersionMinor() const;
@@ -83,6 +86,8 @@
     const LasHeader& getLasHeader() const { return m_lasHeader; }
     LasHeader& getLasHeaderRef() { return m_lasHeader; }
 
+    MetadataRecord& getMetadataRecordRef(int index);
+
 private:
     const std::string m_filename;
     LasHeader m_lasHeader;
diff -r 081987228371 -r 7115cf9d8b9b include/libpc/drivers/las/VariableLengthRecord.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/drivers/las/VariableLengthRecord.hpp	Thu Apr 21 12:06:35 2011 -0700
@@ -0,0 +1,76 @@
+/******************************************************************************
+* Copyright (c) 2011, Michael P. Gerlek (mpg at flaxen.com)
+*
+* 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 Hobu, Inc. or Flaxen Geo Consulting 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,


More information about the Liblas-commits mailing list