Skip to content

Instantly share code, notes, and snippets.

@hobu
Created August 24, 2018 19:41
Show Gist options
  • Select an option

  • Save hobu/d99daf8f1e655ffbd395d512601c71cb to your computer and use it in GitHub Desktop.

Select an option

Save hobu/d99daf8f1e655ffbd395d512601c71cb to your computer and use it in GitHub Desktop.
m_executor = std::shared_ptr<pdal::PipelineExecutor>(new pdal::PipelineExecutor(json));
pdal::PipelineManager& manager = m_executor->getManager();
std::stringstream strm(json);
manager.readPipeline(strm);
pdal::Stage *r = manager.getStage();
if (!r)
throw pdal::pdal_error("pipeline had no stages!");
std::cout << "stage name: " << r->getName() << std::endl;
int counter = 1;
for (auto array: arrays)
{
// Create numpy reader for each array
pdal::Options options;
std::stringstream tag;
tag << "readers_numpy" << counter;
pdal::StageCreationOptions opts { "", "readers.numpy", nullptr, options, tag.str()};
pdal::Stage& reader = manager.makeReader(opts);
pdal::NumpyReader* np_reader = dynamic_cast<pdal::NumpyReader*>(&reader);
if (!np_reader)
throw pdal::pdal_error("couldn't cast reader!");
PyObject* parray = (PyObject*)array->getPythonArray();
if (!parray)
throw pdal::pdal_error("array was none!");
np_reader->setArray(parray);
r->setInput(reader);
std::cout << "stage name: " << r->getName() << std::endl;
counter++;
}
strm.str("");
pdal::PipelineWriter::writePipeline(r, strm);
std::cout << strm.str() << std::endl;
manager.validateStageOptions();
const std::vector<pdal::Stage *> stages = manager.stages();
std::cout << "num stages:" << stages.size() << std::endl;
const std::vector<pdal::Stage *> roots = manager.roots();
std::cout << "roots:" << roots.size() << std::endl;
const std::vector<pdal::Stage *> leaves = manager.leaves();
std::cout << "leaves:" << leaves.size() << std::endl;
@hobu
Copy link
Copy Markdown
Author

hobu commented Aug 24, 2018

  "pipeline":
  [
    {
      "tag": "readers_numpy1",
      "type": "readers.numpy"
    },
    {
      "tag": "readers_numpy2",
      "type": "readers.numpy"
    },
    {
      "tag": "readers_numpy3",
      "type": "readers.numpy"
    },
    {
      "capacity": "25",
      "inputs":
      [
        "readers_numpy1",
        "readers_numpy2",
        "readers_numpy3"
      ],
      "tag": "filters_chipper1",
      "type": "filters.chipper"
    }
  ]
}```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment