Skip to content

Commit

Permalink
Pipeline output as JSON.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Jan 19, 2016
1 parent 2b75f17 commit 64c722a
Show file tree
Hide file tree
Showing 17 changed files with 92 additions and 267 deletions.
14 changes: 1 addition & 13 deletions include/pdal/Filter.hpp
Expand Up @@ -34,34 +34,22 @@

#pragma once

#include <pdal/pdal_internal.hpp>

#include <pdal/Stage.hpp>

namespace pdal
{

class Filter;

//
// supported options:
// <uint32>id
// <bool>debug
// <uint32>verbose
//

class FilterWrapper;

class PDAL_DLL Filter : public Stage
{
friend class FilterWrapper;
public:
Filter() : Stage()
Filter()
{}

// for xml serializion of pipelines
virtual boost::property_tree::ptree serializePipeline() const;

private:
virtual PointViewSet run(PointViewPtr view)
{
Expand Down
2 changes: 1 addition & 1 deletion include/pdal/Metadata.hpp
Expand Up @@ -359,7 +359,7 @@ class PDAL_DLL MetadataNode
MetadataNode addList(const std::string& name)
{ return MetadataNode(m_impl->addList(name)); }

MetadataNode clone(const std::string& name)
MetadataNode clone(const std::string& name) const
{
MetadataNode node;
node.m_impl.reset(new MetadataNodeImpl(*m_impl));
Expand Down
21 changes: 2 additions & 19 deletions include/pdal/Options.hpp
Expand Up @@ -340,27 +340,10 @@ class PDAL_DLL Options
// if option name not present, just returns
void remove(const Option& option);

MetadataNode toMetadata() const
{
MetadataNode cur("options");
std::vector<Option> optList = getOptions();
for (auto oi = optList.begin(); oi != optList.end(); ++oi)
{
Option& opt = *oi;
opt.toMetadata(cur);
}
return cur;
}

void toMetadata(MetadataNode& parent) const
{
MetadataNode cur = parent.add("options");
std::vector<Option> optList = getOptions();
for (auto oi = optList.begin(); oi != optList.end(); ++oi)
{
Option& opt = *oi;
opt.toMetadata(cur);
}
for (auto o : getOptions())
o.toMetadata(parent);
}

// add an option (shortcut version, bypass need for an Option object)
Expand Down
16 changes: 4 additions & 12 deletions include/pdal/PipelineWriter.hpp
Expand Up @@ -35,29 +35,21 @@
#pragma once

#include <pdal/pdal_internal.hpp>
#include <pdal/Options.hpp>
#include <pdal/Metadata.hpp>

#include <map>
#include <string>

#include <boost/property_tree/ptree.hpp>

namespace pdal
{

class Stage;

namespace PipelineWriter
{
void PDAL_DLL writePipeline(Stage *s, const std::string& filename);
void PDAL_DLL writePipeline(Stage *s, std::ostream& strm);
typedef std::map<const Stage *, std::string> TagMap;

void PDAL_DLL writeOptions(boost::property_tree::ptree& tree,
const Options& opts);
void PDAL_DLL writeMetadata(boost::property_tree::ptree& tree,
const MetadataNode& input);
void PDAL_DLL writeMetadata(boost::property_tree::ptree& tree,
const MetadataNodeList& input);
PDAL_DLL void writePipeline(Stage *s, const std::string& filename);
PDAL_DLL void writePipeline(Stage *s, std::ostream& strm);
};

} // namespace pdal
Expand Down
1 change: 0 additions & 1 deletion include/pdal/Reader.hpp
Expand Up @@ -71,7 +71,6 @@ class PDAL_DLL Reader : public Stage
virtual void readerProcessOptions(const Options& options);
virtual point_count_t read(PointViewPtr /*view*/, point_count_t /*num*/)
{ return 0; }
virtual boost::property_tree::ptree serializePipeline() const;
};

} // namespace pdal
Expand Down
8 changes: 3 additions & 5 deletions include/pdal/Stage.hpp
Expand Up @@ -100,10 +100,6 @@ class PDAL_DLL Stage
for (const auto& o : opts.getOptions())
m_options.remove(o);
}
virtual boost::property_tree::ptree serializePipeline() const = 0;
boost::property_tree::ptree serialize(const std::string& name,
const std::string& type) const;

virtual LogPtr log() const
{ return m_log; }
bool isDebug() const
Expand All @@ -117,6 +113,8 @@ class PDAL_DLL Stage
return m_options.getValueOrDefault<uint32_t>("verbose", 0);
}
virtual std::string getName() const = 0;
virtual std::string tagName() const
{ return getName(); }
const std::vector<Stage*>& getInputs() const
{ return m_inputs; }
std::vector<Stage *> findStage(std::string name);
Expand All @@ -126,9 +124,9 @@ class PDAL_DLL Stage
{ return Dimension::IdList(); }
static std::string s_getPluginVersion()
{ return std::string(); }

inline MetadataNode getMetadata() const
{ return m_metadata; }
void serialize(MetadataNode root, PipelineWriter::TagMap& tags) const;

/// Sets the UserCallback to manage progress/cancel operations
void setUserCallback(UserCallback* userCallback)
Expand Down
8 changes: 0 additions & 8 deletions include/pdal/Writer.hpp
Expand Up @@ -34,18 +34,14 @@

#pragma once

#include <pdal/pdal_internal.hpp>
#include <pdal/Options.hpp>
#include <pdal/PointView.hpp>
#include <pdal/Stage.hpp>

#include <string>

namespace pdal
{

class Writer;

class UserCallback;

/// End-stage consumer of PDAL pipeline
Expand All @@ -59,10 +55,6 @@ class PDAL_DLL Writer : public Stage
Writer()
{}

/// Serialize the pipeline to a boost::property_tree::ptree
/// @return boost::property_tree::ptree with xml attributes
virtual boost::property_tree::ptree serializePipeline() const;

protected:
std::string m_filename;
XForm m_xXform;
Expand Down
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Expand Up @@ -76,7 +76,6 @@ set(PDAL_BASE_HPP

set(PDAL_BASE_CPP
DynamicLibrary.cpp
Filter.cpp
gitsha.cpp
GDALUtils.cpp
GlobalEnvironment.cpp
Expand Down
47 changes: 0 additions & 47 deletions src/Filter.cpp

This file was deleted.

4 changes: 1 addition & 3 deletions src/Options.cpp
Expand Up @@ -73,9 +73,7 @@ template<> void Option::setValue(const std::string& value)

void Option::toMetadata(MetadataNode& parent) const
{
MetadataNode child = parent.add(getName());
child.add("value", getValue<std::string>());
child.add("description", getDescription());
parent.add(getName(), getValue<std::string>());
}

//---------------------------------------------------------------------------
Expand Down

0 comments on commit 64c722a

Please sign in to comment.