本文整理汇总了C++中StageFactory::inferWriterDriver方法的典型用法代码示例。如果您正苦于以下问题:C++ StageFactory::inferWriterDriver方法的具体用法?C++ StageFactory::inferWriterDriver怎么用?C++ StageFactory::inferWriterDriver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StageFactory
的用法示例。
在下文中一共展示了StageFactory::inferWriterDriver方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
int TranslateKernel::execute()
{
// setting common options for each stage propagates the debug flag and
// verbosity level
Options readerOptions, filterOptions, writerOptions;
setCommonOptions(readerOptions);
setCommonOptions(filterOptions);
setCommonOptions(writerOptions);
m_manager = std::unique_ptr<PipelineManager>(new PipelineManager);
if (!m_readerType.empty())
{
m_manager->addReader(m_readerType);
}
else
{
StageFactory factory;
std::string driver = factory.inferReaderDriver(m_inputFile);
if (driver.empty())
throw app_runtime_error("Cannot determine input file type of " +
m_inputFile);
m_manager->addReader(driver);
}
if (m_manager == NULL)
throw pdal_error("Error making pipeline\n");
Stage* reader = m_manager->getStage();
if (reader == NULL)
throw pdal_error("Error getting reader\n");
readerOptions.add("filename", m_inputFile);
reader->setOptions(readerOptions);
Stage* stage = reader;
// add each filter provided on the command-line, updating the stage pointer
for (auto const f : m_filterType)
{
std::string filter_name(f);
if (!Utils::startsWith(f, "filters."))
filter_name.insert(0, "filters.");
Stage* filter = &(m_manager->addFilter(filter_name));
if (filter == NULL)
{
std::ostringstream oss;
oss << "Unable to add filter " << filter_name << ". Filter "
"is invalid or plugin could not be loaded. Check "
"'pdal --drivers'.";
throw pdal_error("Error getting filter\n");
}
filter->setOptions(filterOptions);
filter->setInput(*stage);
stage = filter;
}
if (!m_writerType.empty())
{
m_manager->addWriter(m_writerType);
}
else
{
StageFactory factory;
std::string driver = factory.inferWriterDriver(m_outputFile);
if (driver.empty())
throw app_runtime_error("Cannot determine output file type of " +
m_outputFile);
Options options = factory.inferWriterOptionsChanges(m_outputFile);
writerOptions += options;
m_manager->addWriter(driver);
}
Stage* writer = m_manager->getStage();
if (writer == NULL)
throw pdal_error("Error getting writer\n");
writerOptions.add("filename", m_outputFile);
writer->setOptions(writerOptions);
writer->setInput(*stage);
// be sure to recurse through any extra stage options provided by the user
applyExtraStageOptionsRecursive(writer);
m_manager->execute();
if (m_pipelineOutput.size() > 0)
PipelineWriter::writePipeline(m_manager->getStage(), m_pipelineOutput);
return 0;
}
示例2: mergeFile
//.........这里部分代码省略.........
if (!g)
throw pdal_error("Couldn't interpret geometry filter string.");
OGR_L_SetSpatialFilter(m_layer, g.get());
}
std::vector<FileInfo> files;
// Docs are bad here. You need this call even if you haven't read anything
// or nothing happens.
OGR_L_ResetReading(m_layer);
while (true)
{
OGRFeatureH feature = OGR_L_GetNextFeature(m_layer);
if (!feature)
break;
FileInfo fileInfo;
fileInfo.m_filename =
OGR_F_GetFieldAsString(feature, indexes.m_filename);
fileInfo.m_srs =
OGR_F_GetFieldAsString(feature, indexes.m_srs);
files.push_back(fileInfo);
OGR_F_Destroy(feature);
}
StageFactory factory;
MergeFilter merge;
Options cropOptions;
if (!m_bounds.empty())
cropOptions.add("bounds", m_bounds);
else
cropOptions.add("polygon", m_wkt);
for (auto f : files)
{
Stage *premerge = NULL;
std::string driver = factory.inferReaderDriver(f.m_filename);
Stage *reader = factory.createStage(driver);
if (!reader)
{
out << "Unable to create reader for file '" << f.m_filename << "'.";
throw pdal_error(out.str());
}
Options readerOptions;
readerOptions.add("filename", f.m_filename);
reader->setOptions(readerOptions);
premerge = reader;
if (m_tgtSrsString != f.m_srs)
{
Stage *repro = factory.createStage("filters.reprojection");
repro->setInput(*reader);
Options reproOptions;
reproOptions.add("out_srs", m_tgtSrsString);
reproOptions.add("in_srs", f.m_srs);
repro->setOptions(reproOptions);
premerge = repro;
}
// WKT is set, even if we're using a bounding box for fitering, so
// can be used as a test here.
if (!m_wkt.empty())
{
Stage *crop = factory.createStage("filters.crop");
crop->setOptions(cropOptions);
crop->setInput(*premerge);
premerge = crop;
}
merge.setInput(*premerge);
}
std::string driver = factory.inferWriterDriver(m_filespec);
Options factoryOptions = factory.inferWriterOptionsChanges(m_filespec);
Stage *writer = factory.createStage(driver);
if (!writer)
{
out << "Unable to create reader for file '" << m_filespec << "'.";
throw pdal_error(out.str());
}
writer->setInput(merge);
applyExtraStageOptionsRecursive(writer);
Options writerOptions(factoryOptions);
setCommonOptions(writerOptions);
writerOptions.add("filename", m_filespec);
writerOptions.add("offset_x", "auto");
writerOptions.add("offset_y", "auto");
writerOptions.add("offset_z", "auto");
writer->addConditionalOptions(writerOptions);
PointTable table;
writer->prepare(table);
writer->execute(table);
}