[Liblas-commits] hg-main-tree: add nonconst version of getDim
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Apr 13 17:45:11 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/f9945e9b5c1e
changeset: 559:f9945e9b5c1e
user: Michael P. Gerlek <mpg at flaxen.com>
date: Wed Apr 13 14:44:08 2011 -0700
description:
add nonconst version of getDim
Subject: hg-main-tree: refactoring of common code in las/liblas readers/writers
details: http://hg.libpc.orghg-main-tree/rev/c01a41b1f261
changeset: 560:c01a41b1f261
user: Michael P. Gerlek <mpg at flaxen.com>
date: Wed Apr 13 14:44:57 2011 -0700
description:
refactoring of common code in las/liblas readers/writers
Subject: hg-main-tree: merge
details: http://hg.libpc.orghg-main-tree/rev/4de27dfc1ea5
changeset: 561:4de27dfc1ea5
user: Michael P. Gerlek <mpg at flaxen.com>
date: Wed Apr 13 14:45:07 2011 -0700
description:
merge
diffstat:
apps/pc2pc.cpp | 2 +-
include/libpc/Schema.hpp | 1 +
include/libpc/Stage.hpp | 2 +-
include/libpc/drivers/las/Header.hpp | 35 +---
include/libpc/drivers/las/Support.hpp | 109 +++++++++++
include/libpc/drivers/liblas/Reader.hpp | 16 +-
include/libpc/drivers/liblas/Writer.hpp | 3 +-
include/libpc/drivers/oci/Iterator.hpp | 3 -
include/libpc/drivers/oci/Reader.hpp | 2 +-
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 | 120 +++---------
src/drivers/las/Support.cpp | 296 ++++++++++++++++++++++++++++++++
src/drivers/las/Writer.cpp | 120 +++---------
src/drivers/liblas/Iterator.cpp | 67 ++----
src/drivers/liblas/Reader.cpp | 111 +----------
src/drivers/liblas/Writer.cpp | 108 ++--------
src/drivers/oci/Iterator.cpp | 2 +-
test/unit/LiblasWriterTest.cpp | 4 +-
test/unit/OCITest.cpp | 24 ++-
test/unit/support.cpp | 2 +-
24 files changed, 598 insertions(+), 664 deletions(-)
diffs (truncated from 1821 to 300 lines):
diff -r ecdf00941504 -r 4de27dfc1ea5 apps/pc2pc.cpp
--- a/apps/pc2pc.cpp Wed Apr 13 10:58:09 2011 -0700
+++ b/apps/pc2pc.cpp Wed Apr 13 14:45:07 2011 -0700
@@ -200,7 +200,7 @@
//BUG: handle laz writer.setCompressed(false);
- writer.setPointFormat( reader.getPointFormatNumber() );
+ writer.setPointFormat( reader.getPointFormat() );
writer.write(numPoints);
}
diff -r ecdf00941504 -r 4de27dfc1ea5 include/libpc/Schema.hpp
--- a/include/libpc/Schema.hpp Wed Apr 13 10:58:09 2011 -0700
+++ b/include/libpc/Schema.hpp Wed Apr 13 14:45:07 2011 -0700
@@ -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 ecdf00941504 -r 4de27dfc1ea5 include/libpc/Stage.hpp
--- a/include/libpc/Stage.hpp Wed Apr 13 10:58:09 2011 -0700
+++ b/include/libpc/Stage.hpp Wed Apr 13 14:45:07 2011 -0700
@@ -66,7 +66,7 @@
// core properties of all stages
const Schema& getSchema() const;
- boost::uint64_t getNumPoints() const;
+ virtual boost::uint64_t getNumPoints() const;
PointCountType getPointCountType() const;
const Bounds<double>& getBounds() const;
const SpatialReference& getSpatialReference() const;
diff -r ecdf00941504 -r 4de27dfc1ea5 include/libpc/drivers/las/Header.hpp
--- a/include/libpc/drivers/las/Header.hpp Wed Apr 13 10:58:09 2011 -0700
+++ b/include/libpc/drivers/las/Header.hpp Wed Apr 13 14:45:07 2011 -0700
@@ -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 ecdf00941504 -r 4de27dfc1ea5 include/libpc/drivers/las/Support.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/drivers/las/Support.hpp Wed Apr 13 14:45:07 2011 -0700
@@ -0,0 +1,109 @@
+/******************************************************************************
+* 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
+};
+
+
+/// Number of bytes of point record storage in particular format.
+enum PointSize
+{
+ PointSize0 = 20, ///< Size of point record in data format \e 0
+ PointSize1 = 28, ///< Size of point record in data format \e 1
+ PointSize2 = 26, ///< Size of point record in data format \e 2
+ PointSize3 = 34 ///< Size of point record in data format \e 3
+ // other formats not supported
+};
+
+
+// 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 ecdf00941504 -r 4de27dfc1ea5 include/libpc/drivers/liblas/Reader.hpp
--- a/include/libpc/drivers/liblas/Reader.hpp Wed Apr 13 10:58:09 2011 -0700
+++ b/include/libpc/drivers/liblas/Reader.hpp Wed Apr 13 14:45:07 2011 -0700
@@ -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,12 +61,8 @@
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;
-
bool supportsIterator (StageIteratorType t) const
{
if (t == StageIterator_Sequential ) return true;
@@ -98,10 +91,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 ecdf00941504 -r 4de27dfc1ea5 include/libpc/drivers/liblas/Writer.hpp
--- a/include/libpc/drivers/liblas/Writer.hpp Wed Apr 13 10:58:09 2011 -0700
+++ b/include/libpc/drivers/liblas/Writer.hpp Wed Apr 13 14:45:07 2011 -0700
@@ -38,6 +38,7 @@
#include <libpc/libpc.hpp>
#include <libpc/Writer.hpp>
+#include <libpc/drivers/las/Support.hpp>
#include <liblas/liblas.hpp>
@@ -55,7 +56,7 @@
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);
// up to 32 chars (default is "libPC")
diff -r ecdf00941504 -r 4de27dfc1ea5 include/libpc/drivers/oci/Iterator.hpp
--- a/include/libpc/drivers/oci/Iterator.hpp Wed Apr 13 10:58:09 2011 -0700
+++ b/include/libpc/drivers/oci/Iterator.hpp Wed Apr 13 14:45:07 2011 -0700
@@ -65,9 +65,6 @@
boost::scoped_ptr<Block> m_block;
OCILobLocator* m_locator;
- sdo_pc* m_pc;
More information about the Liblas-commits
mailing list