Skip to content

Commit

Permalink
Don't allow sub-options.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Oct 9, 2015
1 parent 00d630d commit 88c4ca5
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 346 deletions.
8 changes: 4 additions & 4 deletions doc/stages/writers.nitf.rst
Expand Up @@ -74,12 +74,12 @@ FSCLTX
File classification text (43 characters) [Default: <spaces>]

AIMIDB
Option tag that should contain further options to complete the AIMIDB
(Additional Image ID) TRE record [Default: None]
Comma separated list of name/value pairs to complete the AIMIDB
(Additional Image ID) TRE record (format name:value) [Default: None]

ACFTB
Option tag that should contain further options to complete the ACFTB
(Aircraft Information) TRE record [Default: None]
Comma separated list of name/value pairs to complete the ACFTB
(Aircraft Information) TRE record (format name:value) [Default: None]


.. _NITF: http://en.wikipedia.org/wiki/National_Imagery_Transmission_Format
Expand Down
116 changes: 5 additions & 111 deletions include/pdal/Options.hpp
Expand Up @@ -55,7 +55,6 @@ class Option;
namespace options
{
typedef std::multimap<std::string, Option> map_t;
typedef std::shared_ptr<Options> OptionsPtr;
}

/*!
Expand Down Expand Up @@ -101,8 +100,7 @@ class PDAL_DLL Option

/// @name Constructors

/// Empty constructor
Option() : m_options(0)
Option()
{}

/// Primary constructor
Expand All @@ -123,26 +121,18 @@ class PDAL_DLL Option
/// Construct from an existing boost::property_tree
Option(const boost::property_tree::ptree& tree);

/// @name Equality
/// Equality
bool equals(const Option& rhs) const
{
return (m_name == rhs.getName() &&
m_value == rhs.getValue<std::string>() &&
m_description == rhs.getDescription() &&
m_options == rhs.m_options);
}

/// Equality operator
bool operator==(const Option& rhs) const
{
return equals(rhs);
return (m_name == rhs.getName() &&
m_value == rhs.getValue<std::string>() &&
m_description == rhs.getDescription());
}

/// Inequality operator
bool operator!=(const Option& rhs) const
{
return (!equals(rhs));
return (! operator == (rhs));
}

/// @name Attribute access
Expand Down Expand Up @@ -201,12 +191,6 @@ class PDAL_DLL Option
\endverbatim
*/

boost::optional<Options const&> getOptions() const;

/// sets the Options set for this Option instance
/// @param op Options set to use
void setOptions(Options const& op);

bool empty() const;

#if defined(PDAL_COMPILER_MSVC)
Expand All @@ -231,7 +215,6 @@ class PDAL_DLL Option
std::string m_name;
std::string m_value;
std::string m_description; // optional field
options::OptionsPtr m_options; // Sub-options.

template <typename T>
void getValue(T& t) const
Expand Down Expand Up @@ -282,27 +265,6 @@ template<> void Option::setValue(const bool& value);
template<> void Option::setValue(const std::string& value);
#endif

/*!
\verbatim embed:rst
An Options object is just a map of names to Option objects.
Dumped as XML, an Options object with two Option objects looks like this:
::
<?xml...>
<Option>
<Name>myname</name>
<Value>17</value>
<Description>my descr</description>
</Option>
<Option>
<Name>myname2</name>
<Value>13</value>
<Description>my descr2</description>
</Option>
\endverbatim
*/
class PDAL_DLL Options
{
public:
Expand Down Expand Up @@ -481,83 +443,15 @@ class PDAL_DLL Options
// returns true iff the option name is valid
bool hasOption(std::string const& name) const;

// the empty options list
// BUG: this should be a member variable, not a function, but doing so
// causes vs2010 to fail to link
static const Options& none();

void dump() const;

std::vector<Option> getOptions(std::string const& name="") const;


template<typename T>
boost::optional<T> getMetadataOption(std::string const& name) const
{
// <Reader type="writers.las">
// <Option name="metadata">
// <Options>
// <Option name="dataformatid">
// 3
// </Option>
// <Option name="filesourceid">
// forward
// </Option>
// <Option name="year">
// forward
// </Option>
// <Option name="day_of_year">
// forward
// </Option>
// <Option name="vlr">
// forward
// <Options>
// <Option name="user_id">
// hobu
// </Option>
// <Option name="record">
// 1234
// </Option>
// </Options>
// </Option>
// </Options>
// </Option>
// </Reader>

Option const* doMetadata(0);
try
{
doMetadata = &getOption("metadata");
}
catch (Option::not_found)
{
return boost::optional<T>();
}

boost::optional<Options const&> meta = doMetadata->getOptions();
if (meta)
{
try
{
meta->getOption(name);
}
catch (Option::not_found)
{
return boost::optional<T>();
}

return boost::optional<T>(meta->getOption(name).getValue<T>());
}
return boost::optional<T>();
}

private:
options::map_t m_options;
};



PDAL_DLL std::ostream& operator<<(std::ostream& ostr, const Options&);


} // namespace pdal
7 changes: 0 additions & 7 deletions include/pdal/PDALUtils.hpp
Expand Up @@ -225,15 +225,8 @@ inline ptree toPTree(const Option& option)
t.put("Name", option.getName());
t.put("Value", option.getValue<std::string>());
if (option.getDescription() != "")
{
t.put("Description", option.getDescription());
}
boost::optional<Options const&> options = option.getOptions();

if (options != boost::none)
{
t.add_child("Options", toPTree(*options));
}
return t;
}

Expand Down
33 changes: 0 additions & 33 deletions io/las/LasWriter.cpp
Expand Up @@ -151,7 +151,6 @@ void LasWriter::processOptions(const Options& options)

fillForwardList(options);
getHeaderOptions(options);
getVlrOptions(options);
}


Expand Down Expand Up @@ -269,38 +268,6 @@ void LasWriter::getHeaderOptions(const Options &options)
setHeaderOption("offset_z", m_offsetZ, options);
}

/// Get VLR-specific options and store for processing with metadata.
/// \param opts Options to check for VLR info.
void LasWriter::getVlrOptions(const Options& opts)
{
std::vector<pdal::Option> options = opts.getOptions("vlr");
for (auto o = options.begin(); o != options.end(); ++o)
{
if (!boost::algorithm::istarts_with(o->getName(), "vlr"))
continue;

boost::optional<pdal::Options const&> vo = o->getOptions();
if (!vo)
continue;

VlrOptionInfo info;
info.m_name = o->getName().substr(strlen("vlr"));
info.m_value = o->getValue<std::string>();
try
{
info.m_recordId = vo->getOption("record_id").getValue<int16_t>();
info.m_userId = vo->getOption("user_id").getValue<std::string>();
}
catch (Option::not_found)
{
continue;
}
info.m_description = vo->getValueOrDefault<std::string>
("description", "");
m_optionInfos.push_back(info);
}
}


void LasWriter::readyTable(PointTableRef table)
{
Expand Down
1 change: 0 additions & 1 deletion io/las/LasWriter.hpp
Expand Up @@ -130,7 +130,6 @@ class PDAL_DLL LasWriter : public FlexWriter

void fillForwardList(const Options& options);
void getHeaderOptions(const Options& options);
void getVlrOptions(const Options& opts);
template <typename T>
void handleForward(const std::string& s, T& headerVal,
const MetadataNode& base);
Expand Down
15 changes: 2 additions & 13 deletions plugins/attribute/filters/AttributeFilter.cpp
Expand Up @@ -115,19 +115,8 @@ Options AttributeFilter::getDefaultOptions()
{
Options options;

pdal::Option red("dimension", "Classification", "");
pdal::Option b0("value","0", "");
pdal::Option query("query","", "");
pdal::Option layer("layer","", "");
pdal::Option datasource("datasource","", "");
pdal::Options redO;
redO.add(b0);
redO.add(query);
redO.add(layer);
redO.add(datasource);
red.setOptions(redO);

options.add(red);
options.add("dimension", "Classification");
options.add("datasource", "source");

return options;
}
Expand Down

0 comments on commit 88c4ca5

Please sign in to comment.