[Liblas-commits] hg-main-tree: set libpc_test data directory from
the command line
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Mar 16 15:13:25 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/cd1a23c1b289
changeset: 289:cd1a23c1b289
user: Kirk McKelvey <kirkoman at gmail.com>
date: Wed Mar 16 13:23:10 2011 -0500
description:
set libpc_test data directory from the command line
Subject: hg-main-tree: merge
details: http://hg.libpc.orghg-main-tree/rev/be26be68d21c
changeset: 290:be26be68d21c
user: Kirk McKelvey <kirkoman at gmail.com>
date: Wed Mar 16 14:13:18 2011 -0500
description:
merge
diffstat:
include/libpc/Filter.hpp | 5 -
include/libpc/Iterator.hpp | 52 ++++++++++++++++++
include/libpc/Reader.hpp | 4 -
include/libpc/drivers/oci/Reader.hpp | 2 +
include/libpc/filters/CropFilter.hpp | 2 +
include/libpc/filters/DecimationFilter.hpp | 2 +
include/libpc/filters/MosaicFilter.hpp | 2 +-
src/CMakeLists.txt | 3 +-
src/Filter.cpp | 6 --
src/Iterator.cpp | 85 ++++++++++++++++++++++++++++++
src/Reader.cpp | 19 ------
src/drivers/oci/Reader.cpp | 20 +++++++
src/filters/CropFilter.cpp | 6 ++
src/filters/DecimationFilter.cpp | 6 ++
src/filters/MosaicFilter.cpp | 6 ++
test/unit/CMakeLists.txt | 2 +-
test/unit/ChipperTest.cpp | 4 +-
test/unit/CropFilterTest.cpp | 18 +++---
test/unit/LiblasReaderTest.cpp | 4 +-
test/unit/LiblasWriterTest.cpp | 10 ++-
test/unit/main.cpp | 53 ++++++++++++++---
21 files changed, 247 insertions(+), 64 deletions(-)
diffs (truncated from 567 to 300 lines):
diff -r e42e3d5bfd7e -r be26be68d21c include/libpc/Filter.hpp
--- a/include/libpc/Filter.hpp Wed Mar 16 12:11:43 2011 -0500
+++ b/include/libpc/Filter.hpp Wed Mar 16 14:13:18 2011 -0500
@@ -48,11 +48,6 @@
Filter(Stage& prevStage);
protected:
- // advance (or retreat) to the Nth point in the file (absolute,
- // default behaviour for filters is just to call seek on the previous stage
- virtual void seekToPoint(boost::uint64_t pointNum);
-
-protected:
Stage& m_prevStage;
private:
diff -r e42e3d5bfd7e -r be26be68d21c include/libpc/Iterator.hpp
--- a/include/libpc/Iterator.hpp Wed Mar 16 12:11:43 2011 -0500
+++ b/include/libpc/Iterator.hpp Wed Mar 16 14:13:18 2011 -0500
@@ -40,7 +40,59 @@
namespace libpc
{
+class LIBPC_DLL Iterator
+{
+public:
+ Iterator(const Stage& stage);
+ const Stage& getStage() const;
+
+ // This reads a set of points at the current position in the file.
+ //
+ // The schema of the PointData buffer we are given here might
+ // not match our own header's schema. That's okay, though: all
+ // that matters is that the buffer we are given has the fields
+ // we need to write into.
+ //
+ // This is NOT virtual. Derived classes should override the
+ // readBuffer function below, not this one.
+ //
+ // Returns the number of valid points read.
+ boost::uint32_t read(PointData&);
+
+ // advance (or retreat) to the Nth point in the file (absolute,
+ // not relative). In some cases, this might be a very slow, painful
+ // function to call.
+ virtual void seekToPoint(boost::uint64_t pointNum) = 0;
+
+ // Returns the current point number. The first point is 0.
+ // If this number if > getNumPoints(), then no more points
+ // may be read (and atEnd() should be true).
+ boost::uint64_t getCurrentPointIndex() const;
+
+ // returns true after we've read all the points available to this stage
+ // (actually a convenience function that compares getCurrentPointIndex and getNumPoints)
+ bool atEnd() const;
+
+protected:
+ // Implement this to do the actual work to fill in a buffer of points.
+ virtual boost::uint32_t readBuffer(PointData&) = 0;
+
+ // Each concrete stage is repsonsible for managing its own current
+ // point index when a read or seek occurs. Call this function to set
+ // the value.
+ void setCurrentPointIndex(boost::uint64_t delta);
+
+ // this is easier than saying setCurrentPointIndex(getCurrentPointIndex()+n)
+ void incrementCurrentPointIndex(boost::uint64_t currentPointDelta);
+
+private:
+ const Stage& m_stage;
+ boost::uint64_t m_currentPointIndex;
+
+ Iterator& operator=(const Iterator&); // not implemented
+ Iterator(const Iterator&); // not implemented
+};
} // namespace libpc
diff -r e42e3d5bfd7e -r be26be68d21c include/libpc/Reader.hpp
--- a/include/libpc/Reader.hpp Wed Mar 16 12:11:43 2011 -0500
+++ b/include/libpc/Reader.hpp Wed Mar 16 14:13:18 2011 -0500
@@ -46,10 +46,6 @@
public:
Reader();
- // default is to read N points manually
- // override this if you can
- virtual void seekToPoint(boost::uint64_t pointNum);
-
private:
Reader& operator=(const Reader&); // not implemented
Reader(const Reader&); // not implemented
diff -r e42e3d5bfd7e -r be26be68d21c include/libpc/drivers/oci/Reader.hpp
--- a/include/libpc/drivers/oci/Reader.hpp Wed Mar 16 12:11:43 2011 -0500
+++ b/include/libpc/drivers/oci/Reader.hpp Wed Mar 16 14:13:18 2011 -0500
@@ -57,6 +57,8 @@
~Reader();
const std::string& getName() const;
+
+ void seekToPoint(boost::uint64_t pointNum);
private:
diff -r e42e3d5bfd7e -r be26be68d21c include/libpc/filters/CropFilter.hpp
--- a/include/libpc/filters/CropFilter.hpp Wed Mar 16 12:11:43 2011 -0500
+++ b/include/libpc/filters/CropFilter.hpp Wed Mar 16 14:13:18 2011 -0500
@@ -50,6 +50,8 @@
const std::string& getName() const;
+ void seekToPoint(boost::uint64_t pointNum);
+
private:
boost::uint32_t readBuffer(PointData&);
diff -r e42e3d5bfd7e -r be26be68d21c include/libpc/filters/DecimationFilter.hpp
--- a/include/libpc/filters/DecimationFilter.hpp Wed Mar 16 12:11:43 2011 -0500
+++ b/include/libpc/filters/DecimationFilter.hpp Wed Mar 16 14:13:18 2011 -0500
@@ -50,6 +50,8 @@
const std::string& getName() const;
+ void seekToPoint(boost::uint64_t pointNum);
+
private:
boost::uint32_t readBuffer(PointData&);
diff -r e42e3d5bfd7e -r be26be68d21c include/libpc/filters/MosaicFilter.hpp
--- a/include/libpc/filters/MosaicFilter.hpp Wed Mar 16 12:11:43 2011 -0500
+++ b/include/libpc/filters/MosaicFilter.hpp Wed Mar 16 14:13:18 2011 -0500
@@ -49,7 +49,7 @@
const std::string& getName() const;
- // BUG: what does seetToPoint() do for a mosaic filter?
+ void seekToPoint(boost::uint64_t pointNum);
private:
boost::uint32_t readBuffer(PointData&);
diff -r e42e3d5bfd7e -r be26be68d21c src/CMakeLists.txt
--- a/src/CMakeLists.txt Wed Mar 16 12:11:43 2011 -0500
+++ b/src/CMakeLists.txt Wed Mar 16 14:13:18 2011 -0500
@@ -41,7 +41,6 @@
${LIBPC_HEADERS_DIR}/DimensionLayout.hpp
${LIBPC_HEADERS_DIR}/Filter.hpp
${LIBPC_HEADERS_DIR}/Header.hpp
- ${LIBPC_HEADERS_DIR}/Iterator.hpp
${LIBPC_HEADERS_DIR}/Metadata.hpp
${LIBPC_HEADERS_DIR}/Vector.hpp
${LIBPC_HEADERS_DIR}/PointData.hpp
@@ -199,7 +198,7 @@
${LIBPC_HEADERS_DIR}/filters/MosaicFilter.hpp
)
-set (LIBPC_FILTERS_HPP
+set (LIBPC_FILTERS_CPP
./filters/CacheFilter.cpp
./filters/ColorFilter.cpp
./filters/CropFilter.cpp
diff -r e42e3d5bfd7e -r be26be68d21c src/Filter.cpp
--- a/src/Filter.cpp Wed Mar 16 12:11:43 2011 -0500
+++ b/src/Filter.cpp Wed Mar 16 14:13:18 2011 -0500
@@ -48,10 +48,4 @@
}
-void Filter::seekToPoint(boost::uint64_t pointNum)
-{
- m_prevStage.seekToPoint(pointNum);
-}
-
-
} // namespace libpc
diff -r e42e3d5bfd7e -r be26be68d21c src/Iterator.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Iterator.cpp Wed Mar 16 14:13:18 2011 -0500
@@ -0,0 +1,85 @@
+/******************************************************************************
+* 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.
+****************************************************************************/
+
+#include <libpc/Iterator.hpp>
+
+namespace libpc
+{
+
+
+Iterator::Iterator(const Stage& stage)
+ : m_stage(stage)
+ , m_currentPointIndex(0)
+{
+ return;
+}
+
+
+const Stage& Iterator::getStage() const
+{
+ return m_stage;
+}
+
+
+void Iterator::setCurrentPointIndex(boost::uint64_t currentPointIndex)
+{
+ m_currentPointIndex = currentPointIndex;
+}
+
+
+boost::uint64_t Iterator::getCurrentPointIndex() const
+{
+ return m_currentPointIndex;
+}
+
+void Iterator::incrementCurrentPointIndex(boost::uint64_t delta)
+{
+ m_currentPointIndex += delta;
+}
+
+
+boost::uint32_t Iterator::read(PointData& data)
+{
+ const boost::uint32_t numPointsRead = readBuffer(data);
+ return numPointsRead;
+}
+
+
+bool Iterator::atEnd() const
+{
+ return getCurrentPointIndex() >= getStage().getNumPoints();
+}
+
+
+} // namespace libpc
diff -r e42e3d5bfd7e -r be26be68d21c src/Reader.cpp
--- a/src/Reader.cpp Wed Mar 16 12:11:43 2011 -0500
+++ b/src/Reader.cpp Wed Mar 16 14:13:18 2011 -0500
@@ -44,24 +44,5 @@
}
-void Reader::seekToPoint(boost::uint64_t pointNum)
-{
- if (pointNum == getCurrentPointIndex())
- {
- return;
- }
-
- setCurrentPointIndex(0);
-
- // we read the points only to get to the right place -- we
- // will just drop the points on the floor and return
- boost::uint32_t pointNumX = (boost::uint32_t)pointNum; // BUG
- assert(pointNumX == pointNum);
- PointData pointData(getHeader().getSchema(), pointNumX);
- read(pointData);
-
- return;
-}
-
} // namespace libpc
diff -r e42e3d5bfd7e -r be26be68d21c src/drivers/oci/Reader.cpp
--- a/src/drivers/oci/Reader.cpp Wed Mar 16 12:11:43 2011 -0500
+++ b/src/drivers/oci/Reader.cpp Wed Mar 16 14:13:18 2011 -0500
@@ -73,5 +73,25 @@
return;
}
+void Reader::seekToPoint(boost::uint64_t pointNum)
+{
More information about the Liblas-commits
mailing list