[Liblas-commits] hg: consolidate Dimension into a single class,
start on PTree
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Sep 1 22:13:22 EDT 2010
changeset 36376dc3620d in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=36376dc3620d
summary: consolidate Dimension into a single class, start on PTree
diffstat:
apps/las2las2.cpp | 1 +
include/liblas/lasheader.hpp | 2 -
include/liblas/lasreader.hpp | 2 +
include/liblas/lasschema.hpp | 105 ++++++---------
src/lasschema.cpp | 285 +++++++++++-------------------------------
5 files changed, 123 insertions(+), 272 deletions(-)
diffs (truncated from 645 to 300 lines):
diff -r 1a800948d1ca -r 36376dc3620d apps/las2las2.cpp
--- a/apps/las2las2.cpp Wed Sep 01 09:44:06 2010 -0500
+++ b/apps/las2las2.cpp Wed Sep 01 21:13:08 2010 -0500
@@ -180,6 +180,7 @@
top.add_child("summary.header",reader.GetHeader().GetPTree());
top.add_child("summary.points",pts);
liblas::property_tree::write_xml("junk.xml", top);
+ liblas::property_tree::write_xml("schema.xml", reader.GetHeader().GetSchema().GetPTree());
delete writer;
delete ofs;
diff -r 1a800948d1ca -r 36376dc3620d include/liblas/lasheader.hpp
--- a/include/liblas/lasheader.hpp Wed Sep 01 09:44:06 2010 -0500
+++ b/include/liblas/lasheader.hpp Wed Sep 01 21:13:08 2010 -0500
@@ -393,8 +393,6 @@
boost::uint16_t m_headerSize;
boost::uint32_t m_dataOffset;
boost::uint32_t m_recordsCount;
- // PointFormatName m_dataFormatId;
- // boost::uint16_t m_dataRecordLen;
boost::uint32_t m_pointRecordsCount;
RecordsByReturnArray m_pointRecordsByReturn;
PointScales m_scales;
diff -r 1a800948d1ca -r 36376dc3620d include/liblas/lasreader.hpp
--- a/include/liblas/lasreader.hpp Wed Sep 01 09:44:06 2010 -0500
+++ b/include/liblas/lasreader.hpp Wed Sep 01 21:13:08 2010 -0500
@@ -159,6 +159,8 @@
/// the internal transform creation
void SetTransforms(std::vector<liblas::TransformPtr> const& transforms) {m_transforms = transforms;}
+ /// Summarize the file represented by the reader in the form of a
+ /// property_tree.
liblas::property_tree::ptree Summarize();
private:
diff -r 1a800948d1ca -r 36376dc3620d include/liblas/lasschema.hpp
--- a/include/liblas/lasschema.hpp Wed Sep 01 09:44:06 2010 -0500
+++ b/include/liblas/lasschema.hpp Wed Sep 01 21:13:08 2010 -0500
@@ -43,7 +43,7 @@
#define LIBLAS_SCHEMA_HPP_INCLUDED
#include <liblas/lasversion.hpp>
-
+#include <liblas/external/property_tree/ptree.hpp>
// boost
#include <boost/cstdint.hpp>
#include <boost/any.hpp>
@@ -66,9 +66,9 @@
// Schema();
Schema(PointFormatName data_format_id);
+ Schema(VariableRecord const& vlr);
Schema& operator=(Schema const& rhs);
Schema(Schema const& other);
-
~Schema() {};
@@ -95,6 +95,8 @@
std::vector<std::string> GetDimensionNames() const;
+ liblas::property_tree::ptree GetPTree() const;
+
protected:
boost::uint16_t m_size;
@@ -102,11 +104,8 @@
private:
-
-
std::vector<DimensionPtr> m_dimensions;
-
void add_record0_dimensions();
void add_time();
void add_color();
@@ -119,7 +118,15 @@
public:
DimensionI(std::string const& name, boost::uint32_t size_in_bits) :
m_name(name),
- m_bitsize(size_in_bits)
+ m_bitsize(size_in_bits),
+ m_required(false),
+ m_active(false),
+ m_description(std::string("")),
+ m_min(0),
+ m_max(0),
+ m_numeric(false),
+ m_signed(false),
+ m_integer(false)
{};
virtual ~DimensionI() {};
@@ -142,14 +149,39 @@
bool IsRequired() const { return m_required; }
void IsRequired(bool v) { m_required = v; }
+ /// Is this dimension being used. A dimension with
+ /// IsActive false may exist as a placeholder in PointFormatName-specified
+ /// dimensions, but have their IsActive flag set to false. In this
+ /// case, those values may be disregarded.
bool IsActive() const { return m_active; }
void IsActive(bool v) { m_active = v; }
std::string GetDescription() const { return m_description; }
void SetDescription(std::string const& v) { m_description = v; }
+ /// Is this dimension a numeric dimension. Dimensions with IsNumeric == false
+ /// are considered generic bit/byte fields/
+ bool IsNumeric() const { return m_numeric ; }
+ void IsNumeric(bool v) { m_numeric = v; }
+ /// Does this dimension have a sign? Only applicable to dimensions with
+ /// IsNumeric == true.
+ bool IsSigned() const { return m_signed; }
+ void IsSigned(bool v) { m_signed = v; }
+
+ /// Does this dimension interpret to an integer? Only applicable to dimensions
+ /// with IsNumeric == true.
+ bool IsInteger() const { return m_integer; }
+ void IsInteger(bool v) { m_integer = v; }
+
+ /// The minimum value of this dimension as a double
+ double GetMinimum() { return m_min; }
+ void SetMinimum(double min) { m_min = min; }
+ /// The maximum value of this dimension as a double
+ double GetMaximum() { return m_max; }
+ void SetMaximum(double max) { m_max = max; }
+
private:
std::string m_name;
@@ -157,64 +189,13 @@
bool m_required;
bool m_active;
std::string m_description;
+ double m_min;
+ double m_max;
+ bool m_numeric;
+ bool m_signed;
+ bool m_integer;
};
-template <typename T>
-class NumericDimension : public DimensionI
-{
-public:
-
- NumericDimension(std::string const& name,
- T type,
- boost::uint32_t size_in_bits ) :
- DimensionI(name, size_in_bits),
- m_min(std::numeric_limits<T>::min()),
- m_max(std::numeric_limits<T>::max()),
- m_type(type)
- {
-
- };
-
- NumericDimension& operator=(NumericDimension const& rhs);
- NumericDimension(DimensionI const& other);
-
- ~NumericDimension() {};
-
-
- T const& GetMin() { return m_min; }
- void SetMax(T const& max) { m_max = max; }
-
- T const& GetMax() { return m_max; }
- void SetMin(T const& min) { m_min = min; }
-
-
-
-
-private:
-
- T m_min;
- T m_max;
-
-
- T m_type;
-};
-
-
-class ByteDimension : public DimensionI
-{
-public:
-
- ByteDimension(std::string const& name,
- boost::uint32_t size_in_bits ) :
- DimensionI(name, size_in_bits)
- {
-
- };
-
- ByteDimension& operator=(ByteDimension const& rhs);
- ByteDimension(DimensionI const& other);
-
-};
} // namespace liblas
diff -r 1a800948d1ca -r 36376dc3620d src/lasschema.cpp
--- a/src/lasschema.cpp Wed Sep 01 09:44:06 2010 -0500
+++ b/src/lasschema.cpp Wed Sep 01 21:13:08 2010 -0500
@@ -51,181 +51,6 @@
namespace liblas {
-// void Schema::updatesize(boost::uint16_t new_size) {
-//
-// // if the difference between the new size we're given
-// // and our existing size is 0, do nothing.
-// if ((new_size - m_size) != 0)
-// {
-// // Use the larger of either our base size (accounting for
-// // color, time, etc) and the size we were given.
-// m_size = std::max(new_size, m_base_size);
-// }
-// }
-//
-// boost::uint16_t Schema::calculate_base_size() {
-//
-// boost::uint16_t new_base_size = sizeof(detail::PointRecord);
-//
-// if (HasColor()) {
-// new_base_size += 3 * sizeof(boost::uint16_t);
-// }
-//
-// if (HasTime()) {
-// new_base_size += sizeof(double);
-// }
-// return new_base_size;
-//
-// }
-// void Schema::updatesize() {
-// boost::uint16_t new_base_size = calculate_base_size();
-//
-// // Set to the base if we haven't set it at all yet
-// if (m_size == 0) {
-// m_size = new_base_size;
-// m_base_size = new_base_size;
-// }
-//
-// // Expand or contract the size based on our old difference
-// else {
-//
-// long base_difference = m_base_size - new_base_size;
-//
-// if (base_difference == 0) {
-// return;
-// }
-// else if (base_difference > 0) {
-// // Expand m_size to include new_base_size
-// m_size = m_size + static_cast<boost::uint16_t>(base_difference);
-// m_base_size = new_base_size;
-// }
-// else {
-// m_size = m_size - static_cast<boost::uint16_t>(base_difference);
-// m_base_size = new_base_size;
-// }
-//
-// }
-// }
-//
-// Schema::Schema( boost::uint8_t major,
-// boost::uint8_t minor,
-// boost::uint16_t size) :
-// m_size(size),
-// m_versionminor(minor),
-// m_versionmajor(major),
-// m_hasColor(false),
-// m_hasTime(false),
-// m_base_size(0)
-// {
-// updatesize();
-// }
-//
-//
-// Schema::Schema( boost::uint8_t major,
-// boost::uint8_t minor,
-// boost::uint16_t size,
-// bool bColor,
-// bool bTime) :
-// m_size(size),
-// m_versionminor(minor),
-// m_versionmajor(major),
-// m_hasColor(bColor),
-// m_hasTime(bTime),
-// m_base_size(0)
-// {
-// updatesize();
-// }
-//
-// // copy constructor
-// Schema::Schema(Schema const& other) :
More information about the Liblas-commits
mailing list