[Liblas-commits] hg-main-tree: start of scaling filter
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Apr 27 15:13:15 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/2736b43e979e
changeset: 683:2736b43e979e
user: Michael P. Gerlek <mpg at flaxen.com>
date: Wed Apr 27 12:13:02 2011 -0700
description:
start of scaling filter
diffstat:
include/libpc/filters/ScalingFilter.hpp | 84 ++++++++++
include/libpc/filters/ScalingFilterIterator.hpp | 62 +++++++
src/CMakeLists.txt | 4 +
src/filters/ScalingFilter.cpp | 188 ++++++++++++++++++++++++
src/filters/ScalingFilterIterator.cpp | 72 +++++++++
5 files changed, 410 insertions(+), 0 deletions(-)
diffs (truncated from 443 to 300 lines):
diff -r e4aa6285ff37 -r 2736b43e979e include/libpc/filters/ScalingFilter.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/filters/ScalingFilter.hpp Wed Apr 27 12:13:02 2011 -0700
@@ -0,0 +1,84 @@
+/******************************************************************************
+* 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_FILTERS_SCALINGFILTER_HPP
+#define INCLUDED_FILTERS_SCALINGFILTER_HPP
+
+#include <libpc/libpc.hpp>
+
+#include <boost/shared_ptr.hpp>
+
+#include <libpc/Filter.hpp>
+
+namespace libpc
+{
+ class PointBuffer;
+}
+
+namespace libpc { namespace filters {
+
+class ScalingFilterSequentialIterator;
+
+class LIBPC_DLL ScalingFilter : public Filter
+{
+public:
+ ScalingFilter(const Stage& prevStage);
+
+ const std::string& getDescription() const;
+ const std::string& getName() const;
+
+ bool supportsIterator (StageIteratorType t) const
+ {
+ if (t == StageIterator_Sequential ) return true;
+
+ return false;
+ }
+
+ libpc::SequentialIterator* createSequentialIterator() const;
+ libpc::RandomIterator* createRandomIterator() const { return NULL; }
+
+ void processBuffer(PointBuffer& data) const;
+
+private:
+ void checkImpedance();
+ void initialize();
+
+ ScalingFilter& operator=(const ScalingFilter&); // not implemented
+ ScalingFilter(const ScalingFilter&); // not implemented
+};
+
+
+} } // namespaces
+
+#endif
diff -r e4aa6285ff37 -r 2736b43e979e include/libpc/filters/ScalingFilterIterator.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/filters/ScalingFilterIterator.hpp Wed Apr 27 12:13:02 2011 -0700
@@ -0,0 +1,62 @@
+/******************************************************************************
+* 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_FILTERS_SCALINGFILTERITERATOR_HPP
+#define INCLUDED_FILTERS_SCALINGFILTERITERATOR_HPP
+
+#include <libpc/libpc.hpp>
+
+#include <libpc/filters/ScalingFilter.hpp>
+#include <libpc/FilterIterator.hpp>
+
+namespace libpc { namespace filters {
+
+
+class ScalingFilterSequentialIterator : public libpc::FilterSequentialIterator
+{
+public:
+ ScalingFilterSequentialIterator(const ScalingFilter& filter);
+
+private:
+ boost::uint64_t skipImpl(boost::uint64_t);
+ boost::uint32_t readImpl(PointBuffer&);
+ bool atEndImpl() const;
+
+ const ScalingFilter& m_scalingFilter;
+};
+
+
+} } // namespaces
+
+#endif
diff -r e4aa6285ff37 -r 2736b43e979e src/CMakeLists.txt
--- a/src/CMakeLists.txt Wed Apr 27 12:12:07 2011 -0700
+++ b/src/CMakeLists.txt Wed Apr 27 12:13:02 2011 -0700
@@ -246,6 +246,8 @@
${LIBPC_HEADERS_DIR}/filters/MosaicFilterIterator.hpp
${LIBPC_HEADERS_DIR}/filters/ReprojectionFilter.hpp
${LIBPC_HEADERS_DIR}/filters/ReprojectionFilterIterator.hpp
+ ${LIBPC_HEADERS_DIR}/filters/ScalingFilter.hpp
+ ${LIBPC_HEADERS_DIR}/filters/ScalingFilterIterator.hpp
)
set (LIBPC_FILTERS_CPP
@@ -263,6 +265,8 @@
./filters/MosaicFilterIterator.cpp
./filters/ReprojectionFilter.cpp
./filters/ReprojectionFilterIterator.cpp
+ ./filters/ScalingFilter.cpp
+ ./filters/ScalingFilterIterator.cpp
)
FOREACH(file ${LIBPC_FILTERS_HPP})
diff -r e4aa6285ff37 -r 2736b43e979e src/filters/ScalingFilter.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/filters/ScalingFilter.cpp Wed Apr 27 12:13:02 2011 -0700
@@ -0,0 +1,188 @@
+/******************************************************************************
+* 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/filters/ScalingFilter.hpp>
+
+#include <libpc/Dimension.hpp>
+#include <libpc/Schema.hpp>
+#include <libpc/exceptions.hpp>
+#include <libpc/PointBuffer.hpp>
+#include <libpc/filters/ScalingFilterIterator.hpp>
+
+
+namespace libpc { namespace filters {
+
+
+
+ScalingFilter::ScalingFilter(const Stage& prevStage)
+ : Filter(prevStage)
+{
+ checkImpedance();
+
+ initialize();
+
+ return;
+}
+
+
+void ScalingFilter::checkImpedance()
+{
+ const Schema& schema = this->getSchema();
+
+ if (!schema.hasDimension(Dimension::Field_X, Dimension::Double) ||
+ !schema.hasDimension(Dimension::Field_Y, Dimension::Double) ||
+ !schema.hasDimension(Dimension::Field_Z, Dimension::Double))
+ {
+ throw impedance_invalid("Reprojection filter requires X,Y,Z dimensions as doubles");
+ }
+
+ return;
+}
+
+
+void ScalingFilter::initialize()
+{
+ return;
+}
+
+
+//void ScalingFilter::transform(double& x, double& y, double& z) const
+//{
+//#ifdef LIBPC_HAVE_GDAL
+//
+// int ret = 0;
+//
+// ret = OCTTransform(m_transform_ptr.get(), 1, &x, &y, &z);
+// if (!ret)
+// {
+// std::ostringstream msg;
+// msg << "Could not project point for ReprojectionTransform::" << CPLGetLastErrorMsg() << ret;
+// throw std::runtime_error(msg.str());
+// }
+//
+// //if (m_new_header.get())
+// //{
+// // point.SetHeaderPtr(m_new_header);
+// //}
+//
+// //point.SetX(x);
+// //point.SetY(y);
+// //point.SetZ(z);
+// //
+// //if (detail::compare_distance(point.GetRawX(), (std::numeric_limits<boost::int32_t>::max)()) ||
+// // detail::compare_distance(point.GetRawX(), (std::numeric_limits<boost::int32_t>::min)())) {
+// // throw std::domain_error("X scale and offset combination is insufficient to represent the data");
+// //}
+//
+// //if (detail::compare_distance(point.GetRawY(), (std::numeric_limits<boost::int32_t>::max)()) ||
+// // detail::compare_distance(point.GetRawY(), (std::numeric_limits<boost::int32_t>::min)())) {
+// // throw std::domain_error("Y scale and offset combination is insufficient to represent the data");
+// //}
+//
+// //if (detail::compare_distance(point.GetRawZ(), (std::numeric_limits<boost::int32_t>::max)()) ||
+// // detail::compare_distance(point.GetRawZ(), (std::numeric_limits<boost::int32_t>::min)())) {
+// // throw std::domain_error("Z scale and offset combination is insufficient to represent the data");
+// //}
+//
+//#else
+// boost::ignore_unused_variable_warning(x);
+// boost::ignore_unused_variable_warning(y);
+// boost::ignore_unused_variable_warning(z);
More information about the Liblas-commits
mailing list