Skip to content

Commit

Permalink
Add support for string to/from dimension type conversion.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Aug 28, 2017
1 parent 6ffcca0 commit 5ffbe16
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions io/GDALWriter.cpp
Expand Up @@ -68,6 +68,8 @@ void GDALWriter::addArgs(ProgramArgs& args)
m_options);
args.add("output_type", "Statistics produced ('min', 'max', 'mean', "
"'idw', 'count', 'stdev' or 'all')", m_outputTypeString, {"all"} );
args.add("data_type", "Data type for output grid (\"int8\", \"uint64\", "
"\"float\", etc.)", m_dataType);
args.add("window_size", "Cell distance for fallback interpolation",
m_windowSize);
args.add("nodata", "No data value", m_noData, -9999.0);
Expand Down
1 change: 1 addition & 0 deletions io/GDALWriter.hpp
Expand Up @@ -86,6 +86,7 @@ class PDAL_DLL GDALWriter : public FlexWriter
double m_noData;
Dimension::Id m_interpDim;
std::string m_interpDimString;
Dimension::Type m_dataType;
};

}
19 changes: 18 additions & 1 deletion pdal/DimUtil.hpp
Expand Up @@ -170,7 +170,6 @@ inline Type type(std::string s)
return Type::None;
}


/// Extract a dimension name of a string. Dimension names start with an alpha
/// and continue with numbers or underscores.
/// \param s String from which to extract dimension name.
Expand All @@ -187,6 +186,24 @@ inline std::size_t extractName(const std::string& s, std::string::size_type p)
return Utils::extract(s, p, isvalid) + 1;
}

inline std::istream& operator>>(std::istream& in, Dimension::Type& type)
{
std::string sval;

in >> sval;
type = Dimension::type(sval);
if (type == Dimension::Type::None)
in.setstate(std::ios_base::failbit);
return in;
}

inline std::ostream& operator<<(std::ostream& out, const Dimension::Type& type)
{
out << Dimension::interpretationName(type);
return out;
}

} // namespace Dimension

} // namespace pdal

0 comments on commit 5ffbe16

Please sign in to comment.