From 72ee9ec3d7738812e859602a940e6a6c4323c44f Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Mon, 10 Sep 2012 12:01:37 -0500 Subject: [PATCH] move method for creating a dimension interpretation from the C-style definition to static pdal::Dimension method --- include/pdal/Dimension.hpp | 1 + include/pdal/XMLSchema.hpp | 1 - src/Dimension.cpp | 47 ++++++++++++++++++++++++++++++++++++++ src/XMLSchema.cpp | 47 +------------------------------------- 4 files changed, 49 insertions(+), 47 deletions(-) diff --git a/include/pdal/Dimension.hpp b/include/pdal/Dimension.hpp index 516c8cfb8b..85672e7285 100644 --- a/include/pdal/Dimension.hpp +++ b/include/pdal/Dimension.hpp @@ -439,6 +439,7 @@ class PDAL_DLL Dimension return output; } + static dimension::Interpretation getInterpretation(std::string const& interpretation_name); template inline T convert(void* data) const diff --git a/include/pdal/XMLSchema.hpp b/include/pdal/XMLSchema.hpp index d3f866b462..8054043241 100644 --- a/include/pdal/XMLSchema.hpp +++ b/include/pdal/XMLSchema.hpp @@ -143,7 +143,6 @@ class PDAL_DLL Reader void Initialize(); void Load(); - dimension::Interpretation GetDimensionType(std::string const& interpretation); private: diff --git a/src/Dimension.cpp b/src/Dimension.cpp index f3425c07d9..9a5dfa8f23 100644 --- a/src/Dimension.cpp +++ b/src/Dimension.cpp @@ -287,6 +287,53 @@ std::string Dimension::getInterpretationName() const return type.str(); } + +dimension::Interpretation Dimension::getInterpretation(std::string const& interpretation) +{ + + if (boost::iequals(interpretation, "int8_t") || + boost::iequals(interpretation, "int8")) + return dimension::SignedInteger; + + if (boost::iequals(interpretation, "uint8_t") || + boost::iequals(interpretation, "uint8")) + return dimension::UnsignedInteger; + + if (boost::iequals(interpretation, "int16_t") || + boost::iequals(interpretation, "int16")) + return dimension::SignedInteger; + + if (boost::iequals(interpretation, "uint16_t") || + boost::iequals(interpretation, "uint16")) + return dimension::UnsignedInteger; + + + if (boost::iequals(interpretation, "int32_t") || + boost::iequals(interpretation, "int32")) + return dimension::SignedInteger; + + if (boost::iequals(interpretation, "uint32_t") || + boost::iequals(interpretation, "uint32")) + return dimension::UnsignedInteger; + + if (boost::iequals(interpretation, "int64_t") || + boost::iequals(interpretation, "int64")) + return dimension::SignedInteger; + + if (boost::iequals(interpretation, "uint64_t") || + boost::iequals(interpretation, "uint64")) + return dimension::UnsignedInteger; + + if (boost::iequals(interpretation, "float")) + return dimension::Float; + + if (boost::iequals(interpretation, "double")) + return dimension::Float; + + + return dimension::Undefined; +} + std::ostream& operator<<(std::ostream& os, pdal::Dimension const& d) { using boost::property_tree::ptree; diff --git a/src/XMLSchema.cpp b/src/XMLSchema.cpp index e8276b9c51..a32cf53326 100644 --- a/src/XMLSchema.cpp +++ b/src/XMLSchema.cpp @@ -559,7 +559,7 @@ void Reader::Load() properties = properties->next; } - dimension::Interpretation interp = GetDimensionType(interpretation); + dimension::Interpretation interp = Dimension::getInterpretation(interpretation); Dimension d(name, interp, size, description); if (uuid.size()) @@ -610,51 +610,6 @@ void Reader::Load() } -dimension::Interpretation Reader::GetDimensionType(std::string const& interpretation) -{ - - if (boost::iequals(interpretation, "int8_t") || - boost::iequals(interpretation, "int8")) - return dimension::SignedInteger; - - if (boost::iequals(interpretation, "uint8_t") || - boost::iequals(interpretation, "uint8")) - return dimension::UnsignedInteger; - - if (boost::iequals(interpretation, "int16_t") || - boost::iequals(interpretation, "int16")) - return dimension::SignedInteger; - - if (boost::iequals(interpretation, "uint16_t") || - boost::iequals(interpretation, "uint16")) - return dimension::UnsignedInteger; - - - if (boost::iequals(interpretation, "int32_t") || - boost::iequals(interpretation, "int32")) - return dimension::SignedInteger; - - if (boost::iequals(interpretation, "uint32_t") || - boost::iequals(interpretation, "uint32")) - return dimension::UnsignedInteger; - - if (boost::iequals(interpretation, "int64_t") || - boost::iequals(interpretation, "int64")) - return dimension::SignedInteger; - - if (boost::iequals(interpretation, "uint64_t") || - boost::iequals(interpretation, "uint64")) - return dimension::UnsignedInteger; - - if (boost::iequals(interpretation, "float")) - return dimension::Float; - - if (boost::iequals(interpretation, "double")) - return dimension::Float; - - - return dimension::Undefined; -} Writer::Writer(pdal::Schema const& schema)