[Liblas-commits] hg-main-tree: applyScaling should be a no-op in the case where t...

liblas-commits at liblas.org liblas-commits at liblas.org
Fri May 6 16:42:34 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/232f34c0361b
changeset: 703:232f34c0361b
user:      Howard Butler <hobu.inc at gmail.com>
date:      Fri May 06 15:14:42 2011 -0500
description:
applyScaling should be a no-op in the case where the m_numericScale is 0.0
Subject: hg-main-tree: fix up copyright

details:   http://hg.libpc.orghg-main-tree/rev/969559e617d4
changeset: 704:969559e617d4
user:      Howard Butler <hobu.inc at gmail.com>
date:      Fri May 06 15:42:05 2011 -0500
description:
fix up copyright
Subject: hg-main-tree: add functional QFIT reader with some tests and example files

details:   http://hg.libpc.orghg-main-tree/rev/07bb72893e39
changeset: 705:07bb72893e39
user:      Howard Butler <hobu.inc at gmail.com>
date:      Fri May 06 15:42:22 2011 -0500
description:
add functional QFIT reader with some tests and example files

diffstat:

 include/libpc/Dimension.hpp             |    7 +-
 include/libpc/drivers/qfit/Iterator.hpp |   80 ++++++++++++
 include/libpc/drivers/qfit/Reader.hpp   |   42 ++++++-
 src/CMakeLists.txt                      |    2 +
 src/drivers/oci/Iterator.cpp            |    2 +-
 src/drivers/qfit/Iterator.cpp           |  118 +++++++++++++++++++
 src/drivers/qfit/Reader.cpp             |  198 ++++++++++++++++++++++++++++++-
 test/data/qfit/10-word.qi               |    0 
 test/data/qfit/14-word.qi               |    0 
 test/unit/QFITReaderTest.cpp            |   96 ++++++++++++++-
 10 files changed, 520 insertions(+), 25 deletions(-)

diffs (truncated from 739 to 300 lines):

diff -r 3114d8b05ac7 -r 07bb72893e39 include/libpc/Dimension.hpp
--- a/include/libpc/Dimension.hpp	Fri May 06 10:59:44 2011 -0500
+++ b/include/libpc/Dimension.hpp	Fri May 06 15:42:22 2011 -0500
@@ -239,7 +239,12 @@
     template<class T>
     double applyScaling(T v) const
     {
-        return (double)v * m_numericScale + m_numericOffset;
+        if ( !Utils::compare_approx(m_numericScale, 0.0, (std::numeric_limits<double>::min)()))
+            return (double)v * m_numericScale + m_numericOffset;
+        else 
+        {
+            return v;
+        }
     }
 
     template<class T>
diff -r 3114d8b05ac7 -r 07bb72893e39 include/libpc/drivers/qfit/Iterator.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/drivers/qfit/Iterator.hpp	Fri May 06 15:42:22 2011 -0500
@@ -0,0 +1,80 @@
+/******************************************************************************
+* Copyright (c) 2011, Howard Butler, hobu.inc at gmail.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_QFIT_ITERATOR_HPP
+#define INCLUDED_DRIVERS_QFIT_ITERATOR_HPP
+
+#include <libpc/libpc.hpp>
+
+#include <libpc/Iterator.hpp>
+#include <iosfwd>
+
+
+namespace libpc { namespace drivers { namespace qfit {
+
+class Reader;
+
+class SequentialIterator : public libpc::SequentialIterator
+{
+public:
+    SequentialIterator(const Reader& reader);
+    ~SequentialIterator();
+
+private:
+    boost::uint64_t skipImpl(boost::uint64_t);
+    boost::uint32_t readImpl(PointBuffer&);
+    bool atEndImpl() const;
+
+    const Reader& m_reader;
+    std::istream* m_istream;
+};
+
+
+class RandomIterator : public libpc::RandomIterator
+{
+public:
+    RandomIterator(const Reader& reader);
+    ~RandomIterator();
+
+private:
+    boost::uint64_t seekImpl(boost::uint64_t);
+    boost::uint32_t readImpl(PointBuffer&);
+
+    const Reader& m_reader;
+    std::istream* m_istream;
+};
+
+} } } // namespaces
+
+#endif
diff -r 3114d8b05ac7 -r 07bb72893e39 include/libpc/drivers/qfit/Reader.hpp
--- a/include/libpc/drivers/qfit/Reader.hpp	Fri May 06 10:59:44 2011 -0500
+++ b/include/libpc/drivers/qfit/Reader.hpp	Fri May 06 15:42:22 2011 -0500
@@ -38,14 +38,13 @@
 #include <libpc/libpc.hpp>
 
 #include <libpc/Stage.hpp>
+#include <libpc/Options.hpp>
 
 #include <libpc/SchemaLayout.hpp>
 
 #include <libpc/Iterator.hpp>
 #include <libpc/exceptions.hpp>
 
-#include <boost/scoped_ptr.hpp>
-#include <boost/scoped_array.hpp>
 
 #include <vector>
 
@@ -93,6 +92,31 @@
     {}
 };
 
+class PointIndexes
+{
+public:
+    PointIndexes(const Schema& schema, QFIT_Format_Type format);
+    int Time;
+    int X;
+    int Y;
+    int Z;
+    
+    int StartPulse;
+    int ReflectedPulse;
+    int ScanAngleRank;
+    int Pitch;
+    int Roll;
+    int PDOP;
+    int PulseWidth;
+    int GPSTime;
+    int PassiveSignal;
+    int PassiveX;
+    int PassiveY;
+    int PassiveZ;
+    
+};
+
+
 class LIBPC_DLL Reader : public libpc::Stage
 {
 
@@ -102,19 +126,31 @@
     
     const std::string& getDescription() const;
     const std::string& getName() const;
+    std::string getFileName() const;
+
  
     bool supportsIterator (StageIteratorType t) const
     {   
         if (t == StageIterator_Sequential ) return true;
+        if (t == StageIterator_Random ) return true;
+        
         return false;
     }
 
     boost::uint64_t getNumPoints() { return 0; }
     
     libpc::SequentialIterator* createSequentialIterator() const;
+    libpc::RandomIterator* createRandomIterator() const;
     
     Options& getOptions() const { return m_options; }
 
+    std::size_t getPointDataOffset() const { return m_offset; }
+    boost::uint32_t getPointDataSize() const { return m_size; }
+
+    // this is called by the stage's iterator
+    boost::uint32_t processBuffer(PointBuffer& PointBuffer, std::istream& stream, boost::uint64_t numPointsLeft) const;
+
+
 protected:
     inline QFIT_Format_Type getFormat() const { return m_format; }
 
@@ -125,6 +161,8 @@
 
     Options& m_options;
     QFIT_Format_Type m_format;
+    std::size_t m_offset;
+    boost::uint32_t m_size;
     
     void registerFields();
 
diff -r 3114d8b05ac7 -r 07bb72893e39 src/CMakeLists.txt
--- a/src/CMakeLists.txt	Fri May 06 10:59:44 2011 -0500
+++ b/src/CMakeLists.txt	Fri May 06 15:42:22 2011 -0500
@@ -232,10 +232,12 @@
 # drivers/qfit
 #
 set(LIBPC_DRIVERS_QFIT_HPP
+  ${LIBPC_HEADERS_DIR}/drivers/qfit/Iterator.hpp
   ${LIBPC_HEADERS_DIR}/drivers/qfit/Reader.hpp
 )
 
 set (LIBPC_DRIVERS_QFIT_CPP 
+  ./drivers/qfit/Iterator.cpp
   ./drivers/qfit/Reader.cpp
 )
    
diff -r 3114d8b05ac7 -r 07bb72893e39 src/drivers/oci/Iterator.cpp
--- a/src/drivers/oci/Iterator.cpp	Fri May 06 10:59:44 2011 -0500
+++ b/src/drivers/oci/Iterator.cpp	Fri May 06 15:42:22 2011 -0500
@@ -1,5 +1,5 @@
 /******************************************************************************
-* Copyright (c) 2011, Michael P. Gerlek (mpg at flaxen.com)
+* Copyright (c) 2011, Howard Butler, hobu.inc at gmail.com
 *
 * All rights reserved.
 *
diff -r 3114d8b05ac7 -r 07bb72893e39 src/drivers/qfit/Iterator.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/drivers/qfit/Iterator.cpp	Fri May 06 15:42:22 2011 -0500
@@ -0,0 +1,118 @@
+/******************************************************************************
+* Copyright (c) 2011, Howard Butler, hobu.inc at gmail.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.
+****************************************************************************/
+
+#include <libpc/drivers/qfit/Iterator.hpp>
+
+#include <libpc/drivers/qfit/Reader.hpp>
+#include <libpc/exceptions.hpp>
+#include <libpc/Utils.hpp>
+#include <libpc/PointBuffer.hpp>
+
+#include <iostream>
+
+namespace libpc { namespace drivers { namespace qfit {
+
+
+SequentialIterator::SequentialIterator(const qfit::Reader& reader)
+    : libpc::SequentialIterator(reader)
+    , m_reader(reader)
+    , m_istream(NULL)
+{
+    m_istream = Utils::openFile(m_reader.getFileName());
+    m_istream->seekg(m_reader.getPointDataOffset());
+    return;
+}
+
+
+SequentialIterator::~SequentialIterator()
+{
+    Utils::closeFile(m_istream);
+    return;
+}
+
+
+boost::uint64_t SequentialIterator::skipImpl(boost::uint64_t count)
+{
+    m_istream->seekg( m_reader.getPointDataSize() * count, std::ios::cur);
+    return count;
+}
+
+
+bool SequentialIterator::atEndImpl() const
+{
+    return getIndex() >= getStage().getNumPoints();
+}
+
+


More information about the Liblas-commits mailing list