本文整理汇总了C++中MetadataNode类的典型用法代码示例。如果您正苦于以下问题:C++ MetadataNode类的具体用法?C++ MetadataNode怎么用?C++ MetadataNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MetadataNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findChild
MetadataNode findChild(std::string s) const
{
auto splitString = [](std::string& s) -> std::string
{
std::string val;
size_t pos = s.find(':');
if (pos == std::string::npos)
{
val = s;
s.clear();
}
else
{
val = s.substr(0, pos);
s = (pos == s.size() - 1) ? "" : s.substr(pos + 1);
}
return val;
};
if (s.empty())
return *this;
std::string lname = splitString(s);
auto nodes = children(lname);
for (auto ai = nodes.begin(); ai != nodes.end(); ++ai)
{
MetadataNode& n = *ai;
MetadataNode child = n.findChild(s);
if (!child.empty())
return child;
}
return MetadataNode();
}
示例2: dumpDetail
MetadataNode DeltaKernel::dumpDetail(PointViewPtr& srcView,
PointViewPtr& candView, KD3Index& index, DimIndexMap& dims)
{
MetadataNode root;
for (PointId id = 0; id < srcView->size(); ++id)
{
double x = srcView->getFieldAs<double>(Dimension::Id::X, id);
double y = srcView->getFieldAs<double>(Dimension::Id::Y, id);
double z = srcView->getFieldAs<double>(Dimension::Id::Z, id);
PointId candId = index.neighbor(x, y, z);
MetadataNode delta = root.add("delta");
delta.add("i", id);
for (auto di = dims.begin(); di != dims.end(); ++di)
{
DimIndex& d = di->second;
double sv = srcView->getFieldAs<double>(d.m_srcId, id);
double cv = candView->getFieldAs<double>(d.m_candId, candId);
delta.add(d.m_name, sv - cv);
}
}
return root;
}
示例3: fixedCloud
PointViewPtr IcpFilter::icp(PointViewPtr fixed, PointViewPtr moving) const
{
typedef pcl::PointXYZ Point;
typedef pcl::PointCloud<Point> Cloud;
Cloud::Ptr fixedCloud(new Cloud());
pclsupport::PDALtoPCD(fixed, *fixedCloud);
Cloud::Ptr movingCloud(new Cloud());
pclsupport::PDALtoPCD(moving, *movingCloud);
pcl::IterativeClosestPoint<Point, Point> icp;
icp.setInputSource(movingCloud);
icp.setInputTarget(fixedCloud);
Cloud result;
icp.align(result);
MetadataNode root = getMetadata();
// I couldn't figure out the template-fu to get
// `MetadataNodeImpl::setValue` to work for all Eigen matrices with one
// function, so I'm just brute-forcing the cast for now.
root.add("transform",
Eigen::MatrixXd(icp.getFinalTransformation().cast<double>()));
root.add("converged", icp.hasConverged());
root.add("fitness", icp.getFitnessScore());
assert(moving->size() == result.points.size());
for (PointId i = 0; i < moving->size(); ++i)
{
moving->setField(Dimension::Id::X, i, result.points[i].x);
moving->setField(Dimension::Id::Y, i, result.points[i].y);
moving->setField(Dimension::Id::Z, i, result.points[i].z);
}
return moving;
}
示例4: TEST
// Make sure that we can forward the LAS_Spec/3 VLR
TEST(LasWriterTest, forward_spec_3)
{
PointTable table;
std::string infile(Support::datapath("las/spec_3.las"));
std::string outfile(Support::temppath("out.las"));
// remove file from earlier run, if needed
FileUtils::deleteFile(outfile);
Options readerOpts;
readerOpts.add("filename", infile);
Options writerOpts;
writerOpts.add("forward", "all,vlr");
writerOpts.add("filename", outfile);
LasReader reader;
reader.setOptions(readerOpts);
LasWriter writer;
writer.setOptions(writerOpts);
writer.setInput(reader);
writer.prepare(table);
writer.execute(table);
PointTable t2;
Options readerOpts2;
readerOpts2.add("filename", outfile);
LasReader reader2;
reader2.setOptions(readerOpts2);
reader2.prepare(t2);
reader2.execute(t2);
auto pred = [](MetadataNode temp)
{
auto recPred = [](MetadataNode n)
{
return n.name() == "record_id" &&
n.value() == "3";
};
auto userPred = [](MetadataNode n)
{
return n.name() == "user_id" &&
n.value() == "LASF_Spec";
};
return Utils::startsWith(temp.name(), "vlr_") &&
!temp.findChild(recPred).empty() &&
!temp.findChild(userPred).empty();
};
MetadataNode root = reader2.getMetadata();
MetadataNodeList nodes = root.findChildren(pred);
EXPECT_EQ(nodes.size(), 1u);
}
示例5: while
bool BpfReader::readUlemFiles()
{
BpfUlemFile file;
while (file.read(m_stream))
{
MetadataNode m = m_metadata.add("bundled_file");
m.addEncoded(file.m_filename,
(const unsigned char *)file.m_buf.data(), file.m_len);
}
return (bool)m_stream;
}
示例6: 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);
}
}
}
示例7: find
MetadataNode find(PREDICATE p) const
{
if (p(*this))
return *this;
auto nodes = children();
for (auto ai = nodes.begin(); ai != nodes.end(); ++ai)
{
MetadataNode n = ai->find(p);
if (!n.empty())
return n;
}
return MetadataNode();
}
示例8: 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;
}
示例9: TEST_F
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");
}
示例10: TEST
TEST(XMLSchemaTest, copy)
{
using namespace pdal;
std::string xml = ReadXML(TestConfig::dataPath() +
"../../schemas/16-dim-schema.xml");
std::string xsd = ReadXML(TestConfig::dataPath() + "../../schemas/LAS.xsd");
XMLSchema s1(xml, xsd);
PointTable table;
XMLDimList dims = s1.xmlDims();
for (auto di = dims.begin(); di != dims.end(); ++di)
{
Dimension::Id id =
table.layout()->registerOrAssignDim(
di->m_name,
di->m_dimType.m_type);
s1.setId(di->m_name, id);
}
MetadataNode m;
MetadataNode m1 = m.add("m1", 1u);
MetadataNode m2 = m.add("m2", 1);
MetadataNode m1prime = m.add("m1prime", "Some other metadata");
m1.add("uuid", Uuid());
XMLSchema s2(s1.xmlDims(), m);
std::string xml_output = s2.xml();
XMLSchema s3(xml_output, xsd);
XMLDimList dims3 = s3.xmlDims();
EXPECT_EQ(dims.size(), dims3.size());
auto di1 = dims.begin();
auto di3 = dims3.begin();
while (di1 != dims.end() && di3 != dims3.end())
{
XMLDim& dim1 = *di1;
XMLDim& dim3 = *di3;
EXPECT_EQ(dim1.m_name, dim3.m_name);
EXPECT_EQ(dim1.m_dimType.m_type, dim3.m_dimType.m_type);
di1++;
di3++;
}
}
示例11: findVlrMetadata
/// Search for metadata associated with the provided recordId and userId.
/// \param node - Top-level node to use for metadata search.
/// \param recordId - Record ID to match.
/// \param userId - User ID to match.
MetadataNode LasWriter::findVlrMetadata(MetadataNode node,
uint16_t recordId, const std::string& userId)
{
std::string sRecordId = std::to_string(recordId);
// Find a node whose name starts with vlr and that has child nodes
// with the name and recordId we're looking for.
auto pred = [sRecordId,userId](MetadataNode n)
{
auto recPred = [sRecordId](MetadataNode n)
{
return n.name() == "record_id" &&
n.value() == sRecordId;
};
auto userPred = [userId](MetadataNode n)
{
return n.name() == "user_id" &&
n.value() == userId;
};
return (boost::algorithm::istarts_with(n.name(), "vlr") &&
!n.findChild(recPred).empty() &&
!n.findChild(userPred).empty());
};
return node.find(pred);
}
示例12: addMetadata
void addMetadata(PyObject *list, MetadataNode m)
{
if (!PyList_Check(list))
return;
for (Py_ssize_t i = 0; i < PyList_Size(list); ++i)
{
PyObject *tuple = PyList_GetItem(list, i);
if (!PyTuple_Check(tuple) || PyTuple_Size(tuple) != 5)
continue;
std::string name = readPythonString(tuple, 0);
std::string value = readPythonString(tuple, 1);
std::string type = readPythonString(tuple, 2);
if (type.empty())
type = Metadata::inferType(value);
std::string description = readPythonString(tuple, 3);
PyObject *submeta = PyTuple_GetItem(tuple, 4);
MetadataNode child = m.addWithType(name, value, type, description);
if (submeta)
addMetadata(submeta, child);
}
}
示例13: addMetadata
void addMetadata(PyObject *dict, MetadataNode m)
{
if (! dict)
{
return;
}
if (!PyDict_Check(dict) )
throw pdal::pdal_error("'metadata' member must be a dictionary!");
std::string name = readPythonString(dict, "name");
std::string value = readPythonString(dict, "value");
std::string type = readPythonString(dict, "type");
if (type.empty())
type = Metadata::inferType(value);
std::string description = readPythonString(dict, "description");
PyObject *submeta = PyDict_GetItemString(dict, "children");
if (submeta)
{
if (!PyList_Check(submeta))
throw pdal::pdal_error("'children' metadata member must be a list!");
for (Py_ssize_t i = 0; i < PyList_Size(submeta); ++i)
{
PyObject* p = PyList_GetItem(submeta, i);
addMetadata(p, m);
}
MetadataNode child = m.addWithType(name, value, type, description);
}
}
示例14: toMetadata
inline MetadataNode toMetadata(PointTableRef table)
{
const PointLayoutPtr layout(table.layout());
MetadataNode root;
for (const auto& id : layout->dims())
{
MetadataNode dim("dimensions");
dim.add("name", layout->dimName(id));
Dimension::Type::Enum t = layout->dimType(id);
dim.add("type", Dimension::toName(Dimension::base(t)));
dim.add("size", layout->dimSize(id));
root.addList(dim);
}
return root;
}
示例15: layout
MetadataNode PointView::toMetadata() const
{
MetadataNode node;
const Dimension::IdList& dims = layout()->dims();
for (PointId idx = 0; idx < size(); idx++)
{
MetadataNode pointnode = node.add(std::to_string(idx));
for (auto di = dims.begin(); di != dims.end(); ++di)
{
double v = getFieldAs<double>(*di, idx);
pointnode.add(layout()->dimName(*di), v);
}
}
return node;
}