Skip to content

Commit

Permalink
move method for creating a dimension interpretation from the C-style …
Browse files Browse the repository at this point in the history
…definition to static pdal::Dimension method
  • Loading branch information
hobu committed Sep 10, 2012
1 parent 7e95843 commit 72ee9ec
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 47 deletions.
1 change: 1 addition & 0 deletions include/pdal/Dimension.hpp
Expand Up @@ -439,6 +439,7 @@ class PDAL_DLL Dimension
return output;
}

static dimension::Interpretation getInterpretation(std::string const& interpretation_name);

template <class T>
inline T convert(void* data) const
Expand Down
1 change: 0 additions & 1 deletion include/pdal/XMLSchema.hpp
Expand Up @@ -143,7 +143,6 @@ class PDAL_DLL Reader

void Initialize();
void Load();
dimension::Interpretation GetDimensionType(std::string const& interpretation);

private:

Expand Down
47 changes: 47 additions & 0 deletions src/Dimension.cpp
Expand Up @@ -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;
Expand Down
47 changes: 1 addition & 46 deletions src/XMLSchema.cpp
Expand Up @@ -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())
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 72ee9ec

Please sign in to comment.