[Liblas-commits] hg-main-tree: get rid of need for separate Header
classes (yippee)
liblas-commits at liblas.org
liblas-commits at liblas.org
Fri Mar 25 19:28:01 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/04b612e7d8e9
changeset: 474:04b612e7d8e9
user: Michael P. Gerlek <mpg at flaxen.com>
date: Fri Mar 25 16:27:51 2011 -0700
description:
get rid of need for separate Header classes (yippee)
diffstat:
apps/pc2pc.cpp | 6 +-
include/libpc/Header.hpp | 93 -----------------
include/libpc/Stage.hpp | 43 ++++++-
include/libpc/drivers/las/Header.hpp | 15 ++-
include/libpc/drivers/las/Reader.hpp | 9 +-
include/libpc/drivers/liblas/Header.hpp | 65 ------------
include/libpc/drivers/liblas/Reader.hpp | 4 -
include/libpc/drivers/oci/Header.hpp | 64 ------------
src/Filter.cpp | 7 +-
src/Header.cpp | 170 --------------------------------
src/Iterator.cpp | 2 +-
src/Stage.cpp | 115 +++++++++++++++++++--
src/Writer.cpp | 2 +-
src/drivers/faux/Iterator.cpp | 2 +-
src/drivers/faux/Reader.cpp | 28 +---
src/drivers/las/Header.cpp | 28 ++--
src/drivers/las/LasHeaderReader.cpp | 4 +-
src/drivers/las/LasHeaderReader.hpp | 6 +-
src/drivers/las/Reader.cpp | 22 +---
src/drivers/las/Writer.cpp | 2 +-
src/drivers/liblas/Header.cpp | 58 ----------
src/drivers/liblas/Reader.cpp | 32 +----
src/drivers/liblas/Writer.cpp | 2 +-
src/drivers/oci/header.cpp | 64 ------------
src/filters/Chipper.cpp | 9 +-
src/filters/ColorFilter.cpp | 4 +-
src/filters/CropFilter.cpp | 7 +-
src/filters/DecimationFilter.cpp | 3 +-
src/filters/MosaicFilter.cpp | 22 +--
test/unit/CacheFilterTest.cpp | 2 +-
test/unit/ChipperTest.cpp | 2 +-
test/unit/DecimationFilterTest.cpp | 2 +-
test/unit/FauxReaderTest.cpp | 14 +-
test/unit/LiblasReaderTest.cpp | 10 +-
test/unit/LiblasWriterTest.cpp | 4 +-
test/unit/MosaicFilterTest.cpp | 2 +-
36 files changed, 242 insertions(+), 682 deletions(-)
diffs (truncated from 1637 to 300 lines):
diff -r 64024d55e94f -r 04b612e7d8e9 apps/pc2pc.cpp
--- a/apps/pc2pc.cpp Fri Mar 25 15:12:09 2011 -0700
+++ b/apps/pc2pc.cpp Fri Mar 25 16:27:51 2011 -0700
@@ -108,7 +108,7 @@
{
libpc::drivers::las::LasReader reader(m_inputFile);
- const boost::uint64_t numPoints = reader.getHeader().getNumPoints();
+ const boost::uint64_t numPoints = reader.getNumPoints();
libpc::drivers::las::LasWriter writer(reader, *ofs);
@@ -124,7 +124,7 @@
#ifdef LIBPC_HAVE_ORACLE
libpc::drivers::liblas::LiblasReader reader(m_inputFile);
- const boost::uint64_t numPoints = reader.getHeader().getNumPoints();
+ const boost::uint64_t numPoints = reader.getNumPoints();
libpc::driver::oci::Options options;
boost::property_tree::ptree& tree = options.GetPTree();
@@ -152,7 +152,7 @@
{
libpc::drivers::liblas::LiblasReader reader(m_inputFile);
- const boost::uint64_t numPoints = reader.getHeader().getNumPoints();
+ const boost::uint64_t numPoints = reader.getNumPoints();
libpc::drivers::liblas::LiblasWriter writer(reader, *ofs);
diff -r 64024d55e94f -r 04b612e7d8e9 include/libpc/Header.hpp
--- a/include/libpc/Header.hpp Fri Mar 25 15:12:09 2011 -0700
+++ b/include/libpc/Header.hpp Fri Mar 25 16:27:51 2011 -0700
@@ -1,93 +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_HEADER_HPP
-#define INCLUDED_HEADER_HPP
-
-#include <libpc/libpc.hpp>
-
-#include <libpc/Schema.hpp>
-#include <libpc/Bounds.hpp>
-#include <libpc/SpatialReference.hpp>
-#include <libpc/Metadata.hpp>
-
-namespace libpc
-{
-
-class LIBPC_DLL Header
-{
-public:
- Header();
- Header(const Header&);
- virtual ~Header();
-
- const Schema& getSchema() const;
- Schema& getSchema();
- void setSchema(const Schema&);
-
- boost::uint64_t getNumPoints() const;
- void setNumPoints(boost::uint64_t);
-
- PointCountType getPointCountType() const;
- void setPointCountType(PointCountType);
-
- const Bounds<double>& getBounds() const;
- void setBounds(const Bounds<double>&);
-
- const SpatialReference& getSpatialReference() const;
- void setSpatialReference(const SpatialReference&);
-
- const Metadata::Array& getMetadata() const;
- Metadata::Array& getMetadata();
-
- void dump() const;
-
-private:
- Schema m_schema;
- boost::uint64_t m_numPoints;
- PointCountType m_pointCountType;
- Bounds<double> m_bounds;
- SpatialReference m_spatialReference;
- Metadata::Array m_metadataArray;
-
- Header& operator=(const Header&); // nope
-};
-
-
-LIBPC_DLL std::ostream& operator<<(std::ostream& ostr, const Header&);
-
-
-} // namespace libpc
-
-#endif
diff -r 64024d55e94f -r 04b612e7d8e9 include/libpc/Stage.hpp
--- a/include/libpc/Stage.hpp Fri Mar 25 15:12:09 2011 -0700
+++ b/include/libpc/Stage.hpp Fri Mar 25 16:27:51 2011 -0700
@@ -39,11 +39,14 @@
#include <string>
-
+#include <libpc/Schema.hpp>
+#include <libpc/Bounds.hpp>
+#include <libpc/SpatialReference.hpp>
+#include <libpc/Metadata.hpp>
+
namespace libpc
{
-class Header;
class Iterator;
class SequentialIterator;
class RandomIterator;
@@ -61,31 +64,51 @@
// words. The last word should generally be "Reader" or "Filter".
virtual const std::string& getName() const = 0;
- // returns the number of points this stage has available
- // (actually a convenience function that gets it from the header)
+ // core properties of all stages
+ const Schema& getSchema() const;
boost::uint64_t getNumPoints() const;
-
- const Header& getHeader() const;
- Header& getHeader();
+ PointCountType getPointCountType() const;
+ const Bounds<double>& getBounds() const;
+ const SpatialReference& getSpatialReference() const;
+ const Metadata::Array& getMetadata() const;
virtual bool supportsIterator (StageIteratorType) const { return false; }
-
virtual bool supportsSequentialIterator() const { return false; }
virtual bool supportsRandomIterator() const { return false; }
virtual SequentialIterator* createSequentialIterator() const { return NULL; }
virtual RandomIterator* createRandomIterator() const { return NULL; }
virtual BlockIterator* createBlockIterator() const { return NULL; }
+ void dump() const;
+
protected:
- void setHeader(Header*); // stage takes ownership
+ // setters for the core properties
+ Schema& getSchemaRef();
+ void setSchema(const Schema&);
+ void setNumPoints(boost::uint64_t);
+ void setPointCountType(PointCountType);
+ void setBounds(const Bounds<double>&);
+ void setSpatialReference(const SpatialReference&);
+ Metadata::Array& getMetadata();
+
+ // convenience function, for doing a "copy ctor" on all the core props
+ // (used by the Filter stage, for example)
+ void setCoreProperties(const Stage&);
private:
- Header* m_header;
+ Schema m_schema;
+ boost::uint64_t m_numPoints;
+ 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
};
+LIBPC_DLL std::ostream& operator<<(std::ostream& ostr, const Stage&);
+
} // namespace libpc
#endif
diff -r 64024d55e94f -r 04b612e7d8e9 include/libpc/drivers/las/Header.hpp
--- a/include/libpc/drivers/las/Header.hpp Fri Mar 25 15:12:09 2011 -0700
+++ b/include/libpc/drivers/las/Header.hpp Fri Mar 25 16:27:51 2011 -0700
@@ -45,15 +45,20 @@
#include <libpc/libpc.hpp>
+#include <vector>
+
#include <boost/uuid/uuid.hpp>
+#include <boost/property_tree/ptree.hpp>
-#include <libpc/Header.hpp>
+#include <libpc/Schema.hpp>
+#include <libpc/Vector.hpp>
+#include <libpc/Bounds.hpp>
namespace libpc { namespace drivers { namespace las {
-class LIBPC_DLL LasHeader : public Header
+class LIBPC_DLL LasHeader
{
public:
/// Versions of point record format.
@@ -101,6 +106,7 @@
/// The default constructed header is configured according to the ASPRS
/// LAS 1.2 Specification, point data format set to 0.
/// Other fields filled with 0.
+
LasHeader();
/// Official signature of ASPRS LAS file format, always \b "LASF".
@@ -318,6 +324,9 @@
/// Set minimum values of extent of X, Y and Z coordinates.
void SetMin(double x, double y, double z);
+ const Bounds<double>& getBounds() const { return m_bounds; }
+ void setBounds(const Bounds<double>& bounds) { m_bounds = bounds; }
+
///// Adds a variable length record to the header
//void AddVLR(VariableRecord const& v);
//
@@ -402,6 +411,8 @@
PointFormatId m_data_format_id;
+ Bounds<double> m_bounds;
+
LasHeader& operator=(const LasHeader&); // nope
LasHeader(const LasHeader&); // nope
};
diff -r 64024d55e94f -r 04b612e7d8e9 include/libpc/drivers/las/Reader.hpp
--- a/include/libpc/drivers/las/Reader.hpp Fri Mar 25 15:12:09 2011 -0700
+++ b/include/libpc/drivers/las/Reader.hpp Fri Mar 25 16:27:51 2011 -0700
@@ -38,6 +38,7 @@
#include <libpc/libpc.hpp>
#include <libpc/Stage.hpp>
+#include <libpc/drivers/las/Header.hpp>
namespace libpc
@@ -58,8 +59,6 @@
const std::string& getFileName() const;
- const LasHeader& getLasHeader() const;
-
bool supportsIterator (StageIteratorType t)
{
if (t == StageIterator_Sequential ) return true;
@@ -76,12 +75,14 @@
// this is called by the stage's iterator
boost::uint32_t processBuffer(PointBuffer& PointBuffer, std::istream& stream) const;
+ const LasHeader& getLasHeader() const { return m_lasHeader; }
+
protected:
- LasHeader& getLasHeader();
- void setLasHeader(const LasHeader&);
+ LasHeader& getLasHeaderRef() { return m_lasHeader; }
private:
const std::string m_filename;
+ LasHeader m_lasHeader;
LasReader& operator=(const LasReader&); // not implemented
LasReader(const LasReader&); // not implemented
diff -r 64024d55e94f -r 04b612e7d8e9 include/libpc/drivers/liblas/Header.hpp
--- a/include/libpc/drivers/liblas/Header.hpp Fri Mar 25 15:12:09 2011 -0700
+++ b/include/libpc/drivers/liblas/Header.hpp Fri Mar 25 16:27:51 2011 -0700
More information about the Liblas-commits
mailing list