[Liblas-commits] hg-main-tree: move block define and query type operations from I...

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Apr 14 10:24:49 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/ba5107118150
changeset: 564:ba5107118150
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Apr 14 09:24:34 2011 -0500
description:
move block define and query type operations from Iterator to Reader
Subject: hg-main-tree: merge

details:   http://hg.libpc.orghg-main-tree/rev/69547d1d8d6c
changeset: 565:69547d1d8d6c
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Apr 14 09:24:44 2011 -0500
description:
merge

diffstat:

 apps/pc2pc.cpp                          |    2 +-
 include/libpc/Schema.hpp                |    1 +
 include/libpc/drivers/las/Header.hpp    |   35 +---
 include/libpc/drivers/las/Support.hpp   |   98 ++++++++++
 include/libpc/drivers/liblas/Reader.hpp |   17 +-
 include/libpc/drivers/liblas/Writer.hpp |    7 +-
 include/libpc/drivers/oci/Common.hpp    |    3 +
 include/libpc/drivers/oci/Iterator.hpp  |    5 +-
 include/libpc/drivers/oci/Reader.hpp    |    9 +-
 src/CMakeLists.txt                      |   10 +-
 src/Schema.cpp                          |    6 +
 src/drivers/las/Header.cpp              |  212 +----------------------
 src/drivers/las/LasHeaderReader.cpp     |    5 +-
 src/drivers/las/LasHeaderWriter.cpp     |    2 +-
 src/drivers/las/Reader.cpp              |  148 +++------------
 src/drivers/las/Support.cpp             |  296 ++++++++++++++++++++++++++++++++
 src/drivers/las/Writer.cpp              |  147 +++------------
 src/drivers/liblas/Iterator.cpp         |   67 ++----
 src/drivers/liblas/Reader.cpp           |  106 +---------
 src/drivers/liblas/Writer.cpp           |  118 +++--------
 src/drivers/oci/Iterator.cpp            |  261 +--------------------------
 src/drivers/oci/Reader.cpp              |  204 ++++++++++++++++++++++
 test/data/1.0_0.las                     |    0 
 test/data/1.0_1.las                     |    0 
 test/data/1.1_0.las                     |    0 
 test/data/1.1_1.las                     |    0 
 test/data/1.2_0.las                     |    0 
 test/data/1.2_1.las                     |    0 
 test/data/1.2_2.las                     |    0 
 test/data/1.2_3.las                     |    0 
 test/unit/LiblasReaderTest.cpp          |   67 +++++++
 test/unit/LiblasWriterTest.cpp          |   64 ++++++-
 32 files changed, 927 insertions(+), 963 deletions(-)

diffs (truncated from 2529 to 300 lines):

diff -r 2386479724a7 -r 69547d1d8d6c apps/pc2pc.cpp
--- a/apps/pc2pc.cpp	Wed Apr 13 15:15:13 2011 -0500
+++ b/apps/pc2pc.cpp	Thu Apr 14 09:24:44 2011 -0500
@@ -200,7 +200,7 @@
 
         //BUG: handle laz writer.setCompressed(false);
 
-        writer.setPointFormat( reader.getPointFormatNumber() );
+        writer.setPointFormat( reader.getPointFormat() );
 
         writer.write(numPoints);
     }
diff -r 2386479724a7 -r 69547d1d8d6c include/libpc/Schema.hpp
--- a/include/libpc/Schema.hpp	Wed Apr 13 15:15:13 2011 -0500
+++ b/include/libpc/Schema.hpp	Thu Apr 14 09:24:44 2011 -0500
@@ -74,6 +74,7 @@
     void addDimensions(const std::vector<Dimension>& dims);
 
     const Dimension& getDimension(std::size_t index) const;
+    Dimension& getDimension(std::size_t index);
     const Dimensions& getDimensions() const;
 
     // returns the index of the field
diff -r 2386479724a7 -r 69547d1d8d6c include/libpc/drivers/las/Header.hpp
--- a/include/libpc/drivers/las/Header.hpp	Wed Apr 13 15:15:13 2011 -0500
+++ b/include/libpc/drivers/las/Header.hpp	Thu Apr 14 09:24:44 2011 -0500
@@ -53,7 +53,7 @@
 #include <libpc/Schema.hpp>
 #include <libpc/Vector.hpp>
 #include <libpc/Bounds.hpp>
-
+#include <libpc/drivers/las/Support.hpp>
 
 namespace libpc { namespace drivers { namespace las {
 
@@ -61,27 +61,6 @@
 class LIBPC_DLL LasHeader
 {
 public:
-    /// 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>
@@ -247,10 +226,10 @@
     void SetRecordsCount(boost::uint32_t v);
     
     /// Get identifier of point data (record) format.
-    PointFormatId getDataFormatId() const;
+    libpc::drivers::las::PointFormat getPointFormat() const;
 
     /// Set identifier of point data (record) format.
-    void setDataFormatId(PointFormatId v);
+    void setPointFormat(libpc::drivers::las::PointFormat 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 
@@ -359,9 +338,6 @@
     //void to_xml(std::ostream& os) const;
     //void to_json(std::ostream& os) const;
 
-    // used by LasHeaderReader
-    static void update_required_dimensions(PointFormatId data_format_id, Schema&);
-    
 private:
     typedef Vector<double> PointScales;
     typedef Vector<double> PointOffsets;
@@ -383,9 +359,6 @@
     // TODO (low-priority): replace static-size char arrays
     // with std::string and return const-reference to string object.
     
-    static void add_record0_dimensions(Schema& schema);
-    static void add_time(Schema& schema);
-    static void add_color(Schema& schema);
     
     //
     // Private data members
@@ -409,7 +382,7 @@
     PointOffsets m_offsets;
     bool m_isCompressed;
 
-    PointFormatId m_data_format_id;
+    PointFormat m_pointFormat;
 
     Bounds<double> m_bounds;
 
diff -r 2386479724a7 -r 69547d1d8d6c include/libpc/drivers/las/Support.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/drivers/las/Support.hpp	Thu Apr 14 09:24:44 2011 -0500
@@ -0,0 +1,98 @@
+/******************************************************************************
+* 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_DRIVERS_LAS_SUPPORT_HPP
+#define INCLUDED_DRIVERS_LAS_SUPPORT_HPP
+
+#include <libpc/libpc.hpp>
+
+#include <libpc/Schema.hpp>
+
+namespace libpc { namespace drivers { namespace las {
+
+enum PointFormat
+{
+    PointFormat0 = 0,         // base
+    PointFormat1 = 1,         // base + time
+    PointFormat2 = 2,         // base + color
+    PointFormat3 = 3,         // base + time + color
+    PointFormat4 = 4,         // base + time + wave
+    PointFormat5 = 5,         // base + time + color + wave  (NOT SUPPORTED)
+    PointFormatUnknown = 99
+};
+
+
+// this struct is used as a means to hold all the las field dimension indexes from a schema
+class PointIndexes
+{
+public:
+    PointIndexes(const Schema& schema, PointFormat format);
+    int X;
+    int Y;
+    int Z;
+    
+    int Intensity;
+    int ReturnNumber;
+    int NumberOfReturns;
+    int ScanDirectionFlag;
+    int EdgeOfFlightLine;
+    int Classification;
+    int ScanAngleRank;
+    int UserData;
+    int PointSourceId;
+    
+    int Time;
+    
+    int Red;
+    int Green;
+    int Blue;
+};
+
+
+class LIBPC_DLL Support
+{
+public:
+    static void registerFields(Schema& schema, PointFormat pointFormat);
+    static void setScaling(Schema& schema, double scaleX, double scaleY, double scaleZ, double offsetX, double offsetY, double offsetZ);
+
+    static bool hasTime(PointFormat);
+    static bool hasColor(PointFormat);
+    static bool hasWave(PointFormat);
+    static boost::uint16_t getPointDataSize(PointFormat pointFormat);
+};
+
+
+} } } // namespace
+
+#endif
diff -r 2386479724a7 -r 69547d1d8d6c include/libpc/drivers/liblas/Reader.hpp
--- a/include/libpc/drivers/liblas/Reader.hpp	Wed Apr 13 15:15:13 2011 -0500
+++ b/include/libpc/drivers/liblas/Reader.hpp	Thu Apr 14 09:24:44 2011 -0500
@@ -38,11 +38,8 @@
 #include <libpc/libpc.hpp>
 
 #include <libpc/Stage.hpp>
-//#include <libpc/Iterator.hpp>
 
-//#include <iostream>
-
-//#include <libpc/drivers/liblas/Header.hpp>
+#include <libpc/drivers/las/Support.hpp>
 
 // fwd decls
 namespace liblas
@@ -64,11 +61,10 @@
 
     const std::string& getFileName() const;
 
-    boost::int8_t getPointFormatNumber() const;
+    ::libpc::drivers::las::PointFormat getPointFormat() const;
     
-    bool hasTimeData() const;
-    bool hasColorData() const;
-    bool hasWaveData() const;
+    boost::uint8_t getVersionMajor() const;
+    boost::uint8_t getVersionMinor() const;
 
     bool supportsIterator (StageIteratorType t) const
     {   
@@ -98,10 +94,7 @@
     double m_offsetZ;
     bool m_isCompressed;
     
-    boost::int8_t m_pointFormatNumber; // should be an enum
-    bool m_hasTimeData;
-    bool m_hasColorData;
-    bool m_hasWaveData;
+    ::libpc::drivers::las::PointFormat m_pointFormat;
 
     LiblasReader& operator=(const LiblasReader&); // not implemented
     LiblasReader(const LiblasReader&); // not implemented
diff -r 2386479724a7 -r 69547d1d8d6c include/libpc/drivers/liblas/Writer.hpp
--- a/include/libpc/drivers/liblas/Writer.hpp	Wed Apr 13 15:15:13 2011 -0500
+++ b/include/libpc/drivers/liblas/Writer.hpp	Thu Apr 14 09:24:44 2011 -0500
@@ -38,9 +38,12 @@
 #include <libpc/libpc.hpp>
 
 #include <libpc/Writer.hpp>
+#include <libpc/drivers/las/Support.hpp>
 
 #include <liblas/liblas.hpp>
+#include <liblas/guid.hpp>
 
+#include <boost/uuid/uuid.hpp>
 
 
 namespace libpc { namespace drivers { namespace liblas {
@@ -55,9 +58,11 @@
     const std::string& getName() const;
     
     void setFormatVersion(boost::uint8_t majorVersion, boost::uint8_t minorVersion);
-    void setPointFormat(boost::int8_t pointFormat);
+    void setPointFormat(::libpc::drivers::las::PointFormat);
     void setDate(boost::uint16_t dayOfYear, boost::uint16_t year);
     
+    void setProjectId(const boost::uuids::uuid&);
+
     // up to 32 chars (default is "libPC")
     void setSystemIdentifier(const std::string& systemId); 
     
diff -r 2386479724a7 -r 69547d1d8d6c include/libpc/drivers/oci/Common.hpp
--- a/include/libpc/drivers/oci/Common.hpp	Wed Apr 13 15:15:13 2011 -0500
+++ b/include/libpc/drivers/oci/Common.hpp	Thu Apr 14 09:24:44 2011 -0500
@@ -115,6 +115,7 @@
     boost::int32_t           num_unsorted_points;
     boost::int32_t           pt_sort_dim;
     boost::scoped_ptr<std::vector<uint8_t> > chunk;
+    OCILobLocator           *locator;
     Connection              m_connection;
 
 
@@ -122,6 +123,8 @@
     boost::uint32_t m_capacity;
 };
 
+typedef boost::shared_ptr<Block> BlockPtr;
+
 class LIBPC_DLL Options
 {
 
diff -r 2386479724a7 -r 69547d1d8d6c include/libpc/drivers/oci/Iterator.hpp


More information about the Liblas-commits mailing list