本文整理汇总了C++中StageFactory类的典型用法代码示例。如果您正苦于以下问题:C++ StageFactory类的具体用法?C++ StageFactory怎么用?C++ StageFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StageFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pdal_error
PipelineManagerPtr InfoKernel::makePipeline(const std::string& filename,
bool noPoints)
{
if (!pdal::FileUtils::fileExists(filename))
throw pdal_error("File not found: " + filename);
PipelineManagerPtr output(new PipelineManager);
if (filename == "STDIN")
{
output->readPipeline(std::cin);
}
else if (FileUtils::extension(filename) == ".xml" ||
FileUtils::extension(filename) == ".json")
{
output->readPipeline(filename);
}
else
{
StageFactory factory;
std::string driver = factory.inferReaderDriver(filename);
if (driver.empty())
throw pdal_error("Cannot determine input file type of " + filename);
Stage& reader = output->addReader(driver);
Options ro;
ro.add("filename", filename);
if (noPoints)
ro.add("count", 0);
reader.setOptions(ro);
m_reader = &reader;
}
return output;
}
示例2: TEST
// Test auto scale/offset for streaming mode.
TEST(LasWriterTest, issue1940)
{
StageFactory f;
Stage& r = *(f.createStage("readers.faux"));
Options ro;
ro.add("mode", "constant");
ro.add("bounds", "([55,55],[55,55],[55,55])");
ro.add("count", 20);
r.addOptions(ro);
LasWriter w;
Options wo;
//LogPtr log(new Log("TEST", &std::clog));
//log->setLevel((LogLevel)5);
//w.setLog(log);
wo.add("filename", Support::temppath("out.las"));
wo.add("scale_x", "auto");
wo.add("offset_y", "auto");
w.addOptions(wo);
w.setInput(r);
FixedPointTable t(100);
w.prepare(t);
w.execute(t);
LasTester tester;
LasHeader *h = tester.header(w);
EXPECT_DOUBLE_EQ(h->offsetX(), 0);
EXPECT_DOUBLE_EQ(h->offsetY(), 55);
EXPECT_DOUBLE_EQ(h->scaleX(), 1.0);
EXPECT_DOUBLE_EQ(h->scaleY(), .01);
}
示例3: TEST
TEST(NitfReaderTest, optionSrs)
{
StageFactory f;
Options nitfOpts;
nitfOpts.add("filename", Support::datapath("nitf/autzen-utm10.ntf"));
std::string sr = "PROJCS[\"NAD83 / UTM zone 11N\",GEOGCS[\"NAD83\",DATUM[\"North_American_Datum_1983\",SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6269\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4269\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",-123],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH],AUTHORITY[\"EPSG\",\"26910\"]]";
nitfOpts.add("spatialreference", sr);
PointContext ctx;
ReaderPtr nitfReader(f.createReader("readers.nitf"));
EXPECT_TRUE(nitfReader.get());
nitfReader->setOptions(nitfOpts);
Options lasOpts;
lasOpts.add("filename", "/dev/null");
WriterPtr lasWriter(f.createWriter("writers.las"));
EXPECT_TRUE(lasWriter.get());
lasWriter->setInput(nitfReader.get());
lasWriter->setOptions(lasOpts);;
lasWriter->prepare(ctx);
PointBufferSet pbSet = lasWriter->execute(ctx);
EXPECT_EQ(sr, nitfReader->getSpatialReference().getWKT());
EXPECT_EQ("", lasWriter->getSpatialReference().getWKT());
EXPECT_EQ(sr, ctx.spatialRef().getWKT());
}
示例4: execute
int MyKernel::execute()
{
PointTable table;
StageFactory f;
Stage * reader = f.createStage("readers.las");
Options readerOptions;
readerOptions.add("filename", m_input_file);
reader->setOptions(readerOptions);
Stage * filter = f.createStage("filters.decimation");
Options filterOptions;
filterOptions.add("step", 10);
filter->setOptions(filterOptions);
filter->setInput(*reader);
Stage * writer = f.createStage("writers.text");
Options writerOptions;
writerOptions.add("filename", m_output_file);
writer->setOptions(writerOptions);
writer->setInput(*filter);
writer->prepare(table);
writer->execute(table);
return 0;
}
示例5: readData
void readData()
{
std::ostringstream oss;
oss << "SELECT l.\"OBJ_ID\", l.\"BLK_ID\", l.\"BLK_EXTENT\", " <<
"l.\"BLK_DOMAIN\", l.\"PCBLK_MIN_RES\", l.\"PCBLK_MAX_RES\", " <<
"l.\"NUM_POINTS\", l.\"NUM_UNSORTED_POINTS\", l.\"PT_SORT_DIM\", " <<
"l.\"POINTS\", b.cloud "
"FROM PDAL_TEST_BLOCKS l, PDAL_TEST_BASE b "
"WHERE b.id = l.obj_id ORDER BY l.blk_id ";
Options options = readerOptions();
options.add("query", oss.str());
StageFactory f;
Stage* reader(f.createStage("readers.oci"));
EXPECT_TRUE(reader);
reader->setOptions(options);
PointTable table;
reader->prepare(table);
PointViewSet viewSet = reader->execute(table);
EXPECT_EQ(viewSet.size(), 1u);
PointViewPtr view = *viewSet.begin();
EXPECT_EQ(view->size(), 1065u);
compare(view, Support::datapath("autzen/autzen-utm.las"));
}
示例6: TEST
TEST(LasReaderTest, create)
{
StageFactory f;
auto s = f.createStage("readers.las");
EXPECT_TRUE(s);
}
示例7: TEST
TEST(PtsReader, Constructor)
{
PtsReader reader1;
StageFactory f;
Stage* reader2(f.createStage("readers.pts"));
EXPECT_TRUE(reader2);
}
示例8: TEST
TEST(PlyReader, Constructor)
{
PlyReader reader1;
StageFactory f;
std::unique_ptr<Stage> reader2(f.createStage("readers.ply"));
EXPECT_TRUE(reader2.get());
}
示例9: TEST_F
TEST_F(PredicateFilterTest, PredicateFilterTest_test_programmable)
{
StageFactory f;
BOX3D bounds(0.0, 0.0, 0.0, 2.0, 2.0, 2.0);
Options readerOps;
readerOps.add("bounds", bounds);
readerOps.add("count", 1000);
readerOps.add("mode", "ramp");
FauxReader reader;
reader.setOptions(readerOps);
// keep all points where x less than 1.0
const Option source("source",
// "X < 1.0"
"import numpy as np\n"
"def yow1(ins,outs):\n"
" X = ins['X']\n"
" Mask = np.less(X, 1.0)\n"
" #print X\n"
" #print Mask\n"
" outs['Mask'] = Mask\n"
" return True\n"
);
const Option module("module", "MyModule1");
const Option function("function", "yow1");
Options opts;
opts.add(source);
opts.add(module);
opts.add(function);
Stage* filter(f.createStage("filters.python"));
filter->setOptions(opts);
filter->setInput(reader);
Options statOpts;
std::unique_ptr<StatsFilter> stats(new StatsFilter);
stats->setOptions(statOpts);
stats->setInput(*filter);
PointTable table;
stats->prepare(table);
PointViewSet viewSet = stats->execute(table);
EXPECT_EQ(viewSet.size(), 1u);
const stats::Summary& statsX = stats->getStats(Dimension::Id::X);
const stats::Summary& statsY = stats->getStats(Dimension::Id::Y);
const stats::Summary& statsZ = stats->getStats(Dimension::Id::Z);
EXPECT_TRUE(Utils::compare_approx(statsX.minimum(), 0.0, 0.01));
EXPECT_TRUE(Utils::compare_approx(statsY.minimum(), 0.0, 0.01));
EXPECT_TRUE(Utils::compare_approx(statsZ.minimum(), 0.0, 0.01));
EXPECT_TRUE(Utils::compare_approx(statsX.maximum(), 1.0, 0.01));
EXPECT_TRUE(Utils::compare_approx(statsY.maximum(), 1.0, 0.01));
EXPECT_TRUE(Utils::compare_approx(statsZ.maximum(), 1.0, 0.01));
}
示例10: TEST
TEST(PredicateFilterTest, PredicateFilterTest_test2)
{
StageFactory f;
// same as above, but with 'Y >' instead of 'X <'
BOX3D bounds(0.0, 0.0, 0.0, 2.0, 2.0, 2.0);
Options readerOps;
readerOps.add("bounds", bounds);
readerOps.add("num_points", 1000);
readerOps.add("mode", "ramp");
FauxReader reader;
reader.setOptions(readerOps);
Option source("source",
// "Y > 1.0"
"import numpy as np\n"
"def yow2(ins,outs):\n"
" Y = ins['Y']\n"
" Mask = np.greater(Y, 1.0)\n"
" #print Mask\n"
" outs['Mask'] = Mask\n"
" return True\n"
);
Option module("module", "MyModule1");
Option function("function", "yow2");
Options opts;
opts.add(source);
opts.add(module);
opts.add(function);
std::unique_ptr<Stage> filter(f.createStage("filters.predicate"));
filter->setOptions(opts);
filter->setInput(reader);
Options statOpts;
std::unique_ptr<StatsFilter> stats(new StatsFilter);
stats->setOptions(statOpts);
stats->setInput(*filter);
PointTable table;
stats->prepare(table);
PointViewSet viewSet = stats->execute(table);
EXPECT_EQ(viewSet.size(), 1u);
const stats::Summary& statsX = stats->getStats(Dimension::Id::X);
const stats::Summary& statsY = stats->getStats(Dimension::Id::Y);
const stats::Summary& statsZ = stats->getStats(Dimension::Id::Z);
EXPECT_TRUE(Utils::compare_approx<double>(statsX.minimum(), 1.0, 0.01));
EXPECT_TRUE(Utils::compare_approx<double>(statsY.minimum(), 1.0, 0.01));
EXPECT_TRUE(Utils::compare_approx<double>(statsZ.minimum(), 1.0, 0.01));
EXPECT_TRUE(Utils::compare_approx<double>(statsX.maximum(), 2.0, 0.01));
EXPECT_TRUE(Utils::compare_approx<double>(statsY.maximum(), 2.0, 0.01));
EXPECT_TRUE(Utils::compare_approx<double>(statsZ.maximum(), 2.0, 0.01));
}
示例11: testReadWrite
void testReadWrite(bool compression, bool scaling)
{
FileUtils::deleteFile(tempFilename);
Options writerOptions = getWriterOptions();
if (scaling)
{
writerOptions.add("scale_x", 0.01);
writerOptions.add("scale_y", 0.01);
}
writerOptions.add("compression", compression);
StageFactory f;
{
std::cerr << "*** Writing data!\n";
Options lasReadOpts;
lasReadOpts.add("filename", Support::datapath("las/1.2-with-color.las"));
lasReadOpts.add("count", 11);
LasReader reader;
reader.setOptions(lasReadOpts);
Stage* sqliteWriter(f.createStage("writers.sqlite"));
sqliteWriter->setOptions(writerOptions);
sqliteWriter->setInput(reader);
PointTable table;
sqliteWriter->prepare(table);
sqliteWriter->execute(table);
}
{
Stage* sqliteReader(f.createStage("readers.sqlite"));
sqliteReader->setOptions(getReaderOptions());
PointTable table2;
sqliteReader->prepare(table2);
PointViewSet viewSet = sqliteReader->execute(table2);
EXPECT_EQ(viewSet.size(), 1U);
PointViewPtr view = *viewSet.begin();
using namespace Dimension;
uint16_t reds[] = {68, 54, 112, 178, 134, 99, 90, 106, 106, 100, 64};
for (PointId idx = 0; idx < 11; idx++)
{
uint16_t r = view->getFieldAs<uint16_t>(Id::Red, idx);
EXPECT_EQ(r, reds[idx]);
}
int32_t x = view->getFieldAs<int32_t>(Id::X, 10);
EXPECT_EQ(x, 636038);
double xd = view->getFieldAs<double>(Id::X, 10);
EXPECT_FLOAT_EQ(xd, 636037.53);
}
// FileUtils::deleteFile(tempFilename);
}
示例12: setCommonOptions
int GroundKernel::execute()
{
PointTable table;
Options readerOptions;
readerOptions.add<std::string>("filename", m_inputFile);
setCommonOptions(readerOptions);
Stage& readerStage(Kernel::makeReader(m_inputFile));
readerStage.setOptions(readerOptions);
Options groundOptions;
groundOptions.add<double>("maxWindowSize", m_maxWindowSize);
groundOptions.add<double>("slope", m_slope);
groundOptions.add<double>("maxDistance", m_maxDistance);
groundOptions.add<double>("initialDistance", m_initialDistance);
groundOptions.add<double>("cellSize", m_cellSize);
groundOptions.add<bool>("classify", m_classify);
groundOptions.add<bool>("extract", m_extract);
groundOptions.add<bool>("approximate", m_approximate);
groundOptions.add<bool>("debug", isDebug());
groundOptions.add<uint32_t>("verbose", getVerboseLevel());
StageFactory f;
std::unique_ptr<Stage> groundStage(f.createStage("filters.ground"));
groundStage->setOptions(groundOptions);
groundStage->setInput(readerStage);
// setup the Writer and write the results
Options writerOptions;
writerOptions.add<std::string>("filename", m_outputFile);
setCommonOptions(writerOptions);
Stage& writer(Kernel::makeWriter(m_outputFile, *groundStage));
writer.setOptions(writerOptions);
std::vector<std::string> cmd = getProgressShellCommand();
UserCallback *callback =
cmd.size() ? (UserCallback *)new ShellScriptCallback(cmd) :
(UserCallback *)new HeartbeatCallback();
writer.setUserCallback(callback);
applyExtraStageOptionsRecursive(&writer);
writer.prepare(table);
// process the data, grabbing the PointViewSet for visualization of the
// resulting PointView
PointViewSet viewSetOut = writer.execute(table);
if (isVisualize())
visualize(*viewSetOut.begin());
//visualize(*viewSetIn.begin(), *viewSetOut.begin());
return 0;
}
示例13: TEST
// Test that data from three input views gets written to a single output file.
TEST(NitfWriterTest, flex2)
{
StageFactory f;
Options readerOps;
readerOps.add("filename", Support::datapath("nitf/autzen-utm10.ntf"));
PointTable table;
Stage* reader(f.createStage("readers.nitf"));
reader->setOptions(readerOps);
reader->prepare(table);
PointViewSet views = reader->execute(table);
PointViewPtr v = *(views.begin());
PointViewPtr v1(new PointView(table));
PointViewPtr v2(new PointView(table));
PointViewPtr v3(new PointView(table));
std::vector<PointViewPtr> vs;
vs.push_back(v1);
vs.push_back(v2);
vs.push_back(v3);
for (PointId i = 0; i < v->size(); ++i)
vs[i % 3]->appendPoint(*v, i);
std::string outfile(Support::temppath("test_flex.ntf"));
FileUtils::deleteFile(outfile);
BufferReader reader2;
reader2.addView(v1);
reader2.addView(v2);
reader2.addView(v3);
Options writerOps;
writerOps.add("filename", outfile);
Stage* writer(f.createStage("writers.nitf"));
writer->setOptions(writerOps);
writer->setInput(reader2);
writer->prepare(table);
writer->execute(table);
EXPECT_TRUE(FileUtils::fileExists(outfile));
Options ops;
ops.add("filename", outfile);
Stage* r(f.createStage("readers.nitf"));
r->setOptions(ops);
EXPECT_EQ(r->preview().m_pointCount, v->size());
}
示例14: TEST
TEST(Stats, metadata)
{
BOX3D bounds(1.0, 2.0, 3.0, 101.0, 102.0, 103.0);
Options ops;
ops.add("bounds", bounds);
ops.add("count", 1000);
ops.add("mode", "constant");
StageFactory f;
std::unique_ptr<Stage> reader(f.createStage("readers.faux"));
EXPECT_TRUE(reader.get());
reader->setOptions(ops);
Options filterOps;
filterOps.add("dimensions", " , X, Z ");
StatsFilter filter;
filter.setInput(*reader);
filter.setOptions(filterOps);
PointTable table;
filter.prepare(table);
filter.execute(table);
MetadataNode m = filter.getMetadata();
std::vector<MetadataNode> children = m.children("statistic");
auto findNode = [](MetadataNode m,
const std::string name, const std::string val)
{
auto findNameVal = [name, val](MetadataNode m)
{ return (m.name() == name && m.value() == val); };
return m.find(findNameVal);
};
for (auto mi = children.begin(); mi != children.end(); ++mi)
{
if (findNode(*mi, "name", "X").valid())
{
EXPECT_DOUBLE_EQ(mi->findChild("average").value<double>(), 1.0);
EXPECT_DOUBLE_EQ(mi->findChild("minimum").value<double>(), 1.0);
EXPECT_DOUBLE_EQ(mi->findChild("maximum").value<double>(), 1.0);
EXPECT_DOUBLE_EQ(mi->findChild("count").value<double>(), 1000.0);
}
if (findNode(*mi, "name", "Z").valid())
{
EXPECT_DOUBLE_EQ(mi->findChild("average").value<double>(), 3.0);
EXPECT_DOUBLE_EQ(mi->findChild("minimum").value<double>(), 3.0);
EXPECT_DOUBLE_EQ(mi->findChild("maximum").value<double>(), 3.0);
EXPECT_DOUBLE_EQ(mi->findChild("count").value<double>(), 1000.0);
}
}
}
示例15: visualize
void Kernel::visualize(PointBufferPtr buffer) const
{
BufferReader bufferReader;
bufferReader.addBuffer(buffer);
StageFactory f;
WriterPtr writer(f.createWriter("writers.pclvisualizer"));
writer->setInput(&bufferReader);
PointContext ctx;
writer->prepare(ctx);
writer->execute(ctx);
}