本文整理汇总了C++中MetadataNode::findChild方法的典型用法代码示例。如果您正苦于以下问题:C++ MetadataNode::findChild方法的具体用法?C++ MetadataNode::findChild怎么用?C++ MetadataNode::findChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MetadataNode
的用法示例。
在下文中一共展示了MetadataNode::findChild方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: name
TEST(LasReaderTest, IgnoreVLRs)
{
PointTable table;
Options readOps;
readOps.add("filename", Support::datapath("las/lots_of_vlr.las"));
readOps.add("ignore_vlr", "Merrick");
LasReader reader;
reader.setOptions(readOps);
reader.prepare(table);
PointViewSet viewSet = reader.execute(table);
// First two VLRs are SRS info, the other 388 would be
// Merrick ones that we want to ignore/remove
MetadataNode root = reader.getMetadata();
for (size_t i = 2; i < 390; ++i)
{
std::string name("vlr_");
name += std::to_string(i);
MetadataNode m = root.findChild(name);
EXPECT_FALSE(!m.empty()) << "No node " << i;
m = m.findChild("data");
EXPECT_FALSE(!m.empty()) << "No value for node " << i;
}
}
示例2: handleHeaderForward
void LasWriter::handleHeaderForward(const std::string& s, T& headerVal,
const MetadataNode& base)
{
if (Utils::contains(m_forwards, s) && !headerVal.valSet())
{
MetadataNode invalid = base.findChild(s + "INVALID");
MetadataNode m = base.findChild(s);
if (!invalid.valid() && m.valid())
headerVal.setVal(m.value<typename T::type>());
}
}
示例3: getFileInfo
TIndexKernel::FileInfo TIndexKernel::getFileInfo(KernelFactory& factory,
const std::string& filename)
{
FileInfo fileInfo;
PipelineManager manager;
manager.commonOptions() = m_manager.commonOptions();
manager.stageOptions() = m_manager.stageOptions();
// Need to make sure options get set.
Stage& reader = manager.makeReader(filename, "");
if (m_fastBoundary)
{
QuickInfo qi = reader.preview();
std::stringstream polygon;
polygon << "POLYGON ((";
polygon << qi.m_bounds.minx << " " << qi.m_bounds.miny;
polygon << ", " << qi.m_bounds.maxx << " " << qi.m_bounds.miny;
polygon << ", " << qi.m_bounds.maxx << " " << qi.m_bounds.maxy;
polygon << ", " << qi.m_bounds.minx << " " << qi.m_bounds.maxy;
polygon << ", " << qi.m_bounds.minx << " " << qi.m_bounds.miny;
polygon << "))";
fileInfo.m_boundary = polygon.str();
if (!qi.m_srs.empty())
fileInfo.m_srs = qi.m_srs.getWKT();
}
else
{
Stage& hexer = manager.makeFilter("filters.hexbin", reader);
PointTable table;
hexer.prepare(table);
PointViewSet set = hexer.execute(table);
MetadataNode m = table.metadata();
m = m.findChild("filters.hexbin:boundary");
fileInfo.m_boundary = m.value();
PointViewPtr v = *set.begin();
if (!v->spatialReference().empty())
fileInfo.m_srs = v->spatialReference().getWKT();
}
FileUtils::fileTimes(filename, &fileInfo.m_ctime, &fileInfo.m_mtime);
fileInfo.m_filename = filename;
return fileInfo;
}
示例4: bounds
TEST_F(PythonFilterTest, metadata)
{
StageFactory f;
BOX3D bounds(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
Options ops;
ops.add("bounds", bounds);
ops.add("count", 10);
ops.add("mode", "ramp");
FauxReader reader;
reader.setOptions(ops);
Option source("source", "import numpy\n"
"import sys\n"
"import redirector\n"
"def myfunc(ins,outs):\n"
" global metadata\n"
" #print('before', globals(), file=sys.stderr,)\n"
" metadata = {'name': 'root', 'value': 'a string', 'type': 'string', 'description': 'a description', 'children': [{'name': 'filters.python', 'value': 52, 'type': 'integer', 'description': 'a filter description', 'children': []}, {'name': 'readers.faux', 'value': 'another string', 'type': 'string', 'description': 'a reader description', 'children': []}]}\n"
" # print ('schema', schema, file=sys.stderr,)\n"
" return True\n"
);
Option module("module", "MyModule");
Option function("function", "myfunc");
Options opts;
opts.add(source);
opts.add(module);
opts.add(function);
Stage* filter(f.createStage("filters.python"));
filter->setOptions(opts);
filter->setInput(reader);
PointTable table;
filter->prepare(table);
PointViewSet viewSet = filter->execute(table);
EXPECT_EQ(viewSet.size(), 1u);
PointViewPtr view = *viewSet.begin();
PointLayoutPtr layout(table.layout());
MetadataNode m = table.metadata();
m = m.findChild("filters.python");
MetadataNodeList l = m.children();
EXPECT_EQ(l.size(), 3u);
EXPECT_EQ(l[0].name(), "filters.python");
EXPECT_EQ(l[0].value(), "52");
EXPECT_EQ(l[0].description(), "a filter description");
}
示例5: setSpatialReference
void Stage::setSpatialReference(MetadataNode& m,
const SpatialReference& spatialRef)
{
m_spatialReference = spatialRef;
auto pred = [](MetadataNode m){ return m.name() == "spatialreference"; };
MetadataNode spatialNode = m.findChild(pred);
if (spatialNode.empty())
{
m.add(Utils::toMetadata(spatialRef));
m.add("spatialreference",
spatialRef.getWKT(SpatialReference::eHorizontalOnly, false),
"SRS of this stage");
m.add("comp_spatialreference",
spatialRef.getWKT(SpatialReference::eCompoundOK, false),
"SRS of this stage");
}
}
示例6:
TEST(LasWriterTest, fix1063_1064_1065)
{
std::string outfile = Support::temppath("out.las");
std::string infile = Support::datapath("las/test1_4.las");
FileUtils::deleteFile(outfile);
std::string cmd = "pdal translate --writers.las.forward=all "
"--writers.las.a_srs=\"EPSG:4326\" " + infile + " " + outfile;
std::string output;
Utils::run_shell_command(Support::binpath(cmd), output);
Options o;
o.add("filename", outfile);
LasReader r;
r.setOptions(o);
PointTable t;
r.prepare(t);
PointViewSet s = r.execute(t);
EXPECT_EQ(s.size(), 1u);
PointViewPtr v = *s.begin();
EXPECT_EQ(v->size(), 1000u);
// https://github.com/PDAL/PDAL/issues/1063
for (PointId idx = 0; idx < v->size(); ++idx)
EXPECT_EQ(8, v->getFieldAs<int>(Dimension::Id::ClassFlags, idx));
// https://github.com/PDAL/PDAL/issues/1064
MetadataNode m = r.getMetadata();
m = m.findChild("global_encoding");
EXPECT_EQ(17, m.value<int>());
// https://github.com/PDAL/PDAL/issues/1065
SpatialReference ref = v->spatialReference();
std::string wkt = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]";
EXPECT_EQ(ref.getWKT(), wkt);
}
示例7: dumpPoints
MetadataNode InfoKernel::dumpPoints(PointViewPtr inView) const
{
MetadataNode root;
PointViewPtr outView = inView->makeNew();
// Stick points in a inViewfer.
std::vector<PointId> points = getListOfPoints(m_pointIndexes);
for (size_t i = 0; i < points.size(); ++i)
{
PointId id = (PointId)points[i];
if (id < inView->size())
outView->appendPoint(*inView.get(), id);
}
MetadataNode tree = outView->toMetadata();
std::string prefix("point ");
for (size_t i = 0; i < outView->size(); ++i)
{
MetadataNode n = tree.findChild(std::to_string(i));
n.add("PointId", points[i]);
root.add(n.clone("point"));
}
return root;
}
示例8: nitf_reader
TEST(NitfReaderTest, test_one)
{
StageFactory f;
Options nitf_opts;
nitf_opts.add("filename", Support::datapath("nitf/autzen-utm10.ntf"));
nitf_opts.add("count", 750);
PointTable table;
Stage* nitf_reader(f.createStage("readers.nitf"));
EXPECT_TRUE(nitf_reader);
nitf_reader->setOptions(nitf_opts);
nitf_reader->prepare(table);
PointViewSet pbSet = nitf_reader->execute(table);
EXPECT_EQ(pbSet.size(), 1u);
PointViewPtr view = *pbSet.begin();
// check metadata
MetadataNode m = nitf_reader->getMetadata();
MetadataNode n = m.findChild(
[](MetadataNode& m) {
return m.name() == "IM:0.IGEOLO";
}
);
EXPECT_EQ(n.value(),
"440344N1230429W440344N1230346W440300N1230346W440300N1230429W");
n = m.findChild("FH.FDT");
EXPECT_EQ(n.value(), "20120323002946");
//
// read LAS
//
Options las_opts;
las_opts.add("count", 750);
las_opts.add("filename", Support::datapath("nitf/autzen-utm10.las"));
PointTable table2;
Stage* las_reader(f.createStage("readers.las"));
EXPECT_TRUE(las_reader);
las_reader->setOptions(las_opts);
las_reader->prepare(table2);
PointViewSet pbSet2 = las_reader->execute(table2);
EXPECT_EQ(pbSet2.size(), 1u);
PointViewPtr view2 = *pbSet.begin();
//
//
// compare the two views
//
EXPECT_EQ(view->size(), view2->size());
for (PointId i = 0; i < view2->size(); i++)
{
int32_t nitf_x = view->getFieldAs<int32_t>(Dimension::Id::X, i);
int32_t nitf_y = view->getFieldAs<int32_t>(Dimension::Id::Y, i);
int32_t nitf_z = view->getFieldAs<int32_t>(Dimension::Id::Z, i);
int32_t las_x = view2->getFieldAs<int32_t>(Dimension::Id::X, i);
int32_t las_y = view2->getFieldAs<int32_t>(Dimension::Id::Y, i);
int32_t las_z = view2->getFieldAs<int32_t>(Dimension::Id::Z, i);
EXPECT_EQ(nitf_x, las_x);
EXPECT_EQ(nitf_y, las_y);
EXPECT_EQ(nitf_z, las_z);
}
}
示例9: getFileInfo
TIndexKernel::FileInfo TIndexKernel::getFileInfo(KernelFactory& factory,
const std::string& filename)
{
FileInfo fileInfo;
StageFactory f;
std::string driverName = f.inferReaderDriver(filename);
Stage *s = f.createStage(driverName);
Options ops;
ops.add("filename", filename);
setCommonOptions(ops);
s->setOptions(ops);
applyExtraStageOptionsRecursive(s);
if (m_fastBoundary)
{
QuickInfo qi = s->preview();
std::stringstream polygon;
polygon << "POLYGON ((";
polygon << qi.m_bounds.minx << " " << qi.m_bounds.miny;
polygon << ", " << qi.m_bounds.maxx << " " << qi.m_bounds.miny;
polygon << ", " << qi.m_bounds.maxx << " " << qi.m_bounds.maxy;
polygon << ", " << qi.m_bounds.minx << " " << qi.m_bounds.maxy;
polygon << ", " << qi.m_bounds.minx << " " << qi.m_bounds.miny;
polygon << "))";
fileInfo.m_boundary = polygon.str();
if (!qi.m_srs.empty())
fileInfo.m_srs = qi.m_srs.getWKT();
}
else
{
PointTable table;
Stage *hexer = f.createStage("filters.hexbin");
if (! hexer)
{
std::ostringstream oss;
oss << "Unable to create hexer stage to create boundaries. "
<< "Is PDAL_DRIVER_PATH environment variable set?";
throw pdal_error(oss.str());
}
hexer->setInput(*s);
hexer->prepare(table);
PointViewSet set = hexer->execute(table);
MetadataNode m = table.metadata();
m = m.findChild("filters.hexbin:boundary");
fileInfo.m_boundary = m.value();
PointViewPtr v = *set.begin();
if (!v->spatialReference().empty())
fileInfo.m_srs = v->spatialReference().getWKT();
}
FileUtils::fileTimes(filename, &fileInfo.m_ctime, &fileInfo.m_mtime);
fileInfo.m_filename = filename;
return fileInfo;
}