本文整理汇总了C++中MetadataNode::add方法的典型用法代码示例。如果您正苦于以下问题:C++ MetadataNode::add方法的具体用法?C++ MetadataNode::add怎么用?C++ MetadataNode::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MetadataNode
的用法示例。
在下文中一共展示了MetadataNode::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: dumpSummary
MetadataNode InfoKernel::dumpSummary(const QuickInfo& qi)
{
MetadataNode summary;
summary.add("num_points", qi.m_pointCount);
summary.add("spatial_reference", qi.m_srs.getWKT());
MetadataNode bounds = summary.add("bounds");
MetadataNode x = bounds.add("X");
x.add("min", qi.m_bounds.minx);
x.add("max", qi.m_bounds.maxx);
MetadataNode y = bounds.add("Y");
y.add("min", qi.m_bounds.miny);
y.add("max", qi.m_bounds.maxy);
MetadataNode z = bounds.add("Z");
z.add("min", qi.m_bounds.minz);
z.add("max", qi.m_bounds.maxz);
std::string dims;
auto di = qi.m_dimNames.begin();
while (di != qi.m_dimNames.end())
{
dims += *di;
++di;
if (di != qi.m_dimNames.end())
dims += ", ";
}
summary.add("dimensions", dims);
return summary;
}
示例3: icp
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: ReadXML
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++;
}
}
示例5: extractMetadata
void StatsFilter::extractMetadata(PointTableRef table)
{
uint32_t position(0);
for (auto di = m_stats.begin(); di != m_stats.end(); ++di)
{
const Summary& s = di->second;
MetadataNode t = m_metadata.addList("statistic");
t.add("position", position++);
s.extractMetadata(t);
}
// If we have X, Y, & Z dims, output bboxes
auto xs = m_stats.find(Dimension::Id::X);
auto ys = m_stats.find(Dimension::Id::Y);
auto zs = m_stats.find(Dimension::Id::Z);
if (xs != m_stats.end() &&
ys != m_stats.end() &&
zs != m_stats.end())
{
BOX3D box(xs->second.minimum(), ys->second.minimum(), zs->second.minimum(),
xs->second.maximum(), ys->second.maximum(), zs->second.maximum());
pdal::Polygon p(box);
MetadataNode mbox = Utils::toMetadata(box);
MetadataNode box_metadata = m_metadata.add("bbox");
MetadataNode metadata = box_metadata.add("native");
MetadataNode boundary = metadata.add("boundary", p.json());
MetadataNode bbox = metadata.add(mbox);
SpatialReference ref = table.anySpatialReference();
// if we don't get an SRS from the PointTableRef,
// we won't add another metadata node
if (!ref.empty())
{
p.setSpatialReference(ref);
SpatialReference epsg4326("EPSG:4326");
pdal::Polygon pdd = p.transform(epsg4326);
BOX3D ddbox = pdd.bounds();
MetadataNode epsg_4326_box = Utils::toMetadata(ddbox);
MetadataNode dddbox = box_metadata.add("EPSG:4326");
dddbox.add(epsg_4326_box);
MetadataNode ddboundary = dddbox.add("boundary", pdd.json());
}
}
}
示例6: toMetadata
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;
}
示例7: toMetadata
inline MetadataNode toMetadata(const PointViewPtr view)
{
MetadataNode node;
const Dimension::IdList& dims = view->dims();
for (PointId idx = 0; idx < view->size(); idx++)
{
MetadataNode pointnode = node.add(std::to_string(idx));
for (auto di = dims.begin(); di != dims.end(); ++di)
{
double v = view->getFieldAs<double>(*di, idx);
pointnode.add(Dimension::name(*di), v);
}
}
return node;
}
示例8: dump
void InfoKernel::dump(MetadataNode& root)
{
if (m_showSchema)
root.add(m_manager->pointTable().toMetadata().clone("schema"));
if (m_PointCloudSchemaOutput.size() > 0)
{
#ifdef PDAL_HAVE_LIBXML2
XMLSchema schema(m_manager->pointTable().layout());
std::ostream *out = FileUtils::createFile(m_PointCloudSchemaOutput);
std::string xml(schema.xml());
out->write(xml.c_str(), xml.size());
FileUtils::closeFile(out);
#else
std::cerr << "libxml2 support not enabled, no schema is produced" <<
std::endl;
#endif
}
if (m_showStats)
root.add(m_statsStage->getMetadata().clone("stats"));
if (m_pipelineFile.size() > 0)
PipelineWriter::writePipeline(m_manager->getStage(), m_pipelineFile);
if (m_pointIndexes.size())
{
PointViewSet viewSet = m_manager->views();
assert(viewSet.size() == 1);
root.add(dumpPoints(*viewSet.begin()).clone("points"));
}
if (m_queryPoint.size())
{
PointViewSet viewSet = m_manager->views();
assert(viewSet.size() == 1);
root.add(dumpQuery(*viewSet.begin()));
}
if (m_showMetadata)
{
// If we have a reader cached, this means we
// weren't reading a pipeline file directly. In that
// case, use the metadata from the reader (old behavior).
// Otherwise, return the full metadata of the entire pipeline
if (m_reader)
root.add(m_reader->getMetadata().clone("metadata"));
else
root.add(m_manager->getMetadata().clone("metadata"));
}
if (m_boundary)
{
PointViewSet viewSet = m_manager->views();
assert(viewSet.size() == 1);
root.add(m_hexbinStage->getMetadata().clone("boundary"));
}
}
示例9: 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");
}
}
示例10: execute
int HausdorffKernel::execute()
{
PointTable srcTable;
PointViewPtr srcView = loadSet(m_sourceFile, srcTable);
PointTable candTable;
PointViewPtr candView = loadSet(m_candidateFile, candTable);
double hausdorff = Utils::computeHausdorff(srcView, candView);
MetadataNode root;
root.add("filenames", m_sourceFile);
root.add("filenames", m_candidateFile);
root.add("hausdorff", hausdorff);
root.add("pdal_version", pdal::GetFullVersionString());
Utils::toJSON(root, std::cout);
return 0;
}
示例11: add
static void add(
MetadataNode& parent,
const std::string& name,
const std::string& value
)
{
Json::Value node;
Json::Reader reader;
if (reader.parse(value, node))
add(parent, name, node);
else parent.add(name, value);
}
示例12: dump
MetadataNode DeltaKernel::dump(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);
// It may be faster to put in a special case to avoid having to
// fetch X, Y and Z, more than once but this is simpler and
// I'm thinking in most cases it will make no practical difference.
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);
accumulate(d, sv - cv);
}
}
root.add("source", m_sourceFile);
root.add("candidate", m_candidateFile);
for (auto dpair : dims)
{
DimIndex& d = dpair.second;
MetadataNode dimNode = root.add(d.m_name);
dimNode.add("min", d.m_min);
dimNode.add("max", d.m_max);
dimNode.add("mean", d.m_avg);
}
return root;
}
示例13: run
MetadataNode InfoKernel::run(const std::string& filename)
{
MetadataNode root;
root.add("filename", filename);
if (m_showSummary)
{
QuickInfo qi = m_reader->preview();
MetadataNode summary = dumpSummary(qi).clone("summary");
root.add(summary);
}
else
{
applyExtraStageOptionsRecursive(m_manager->getStage());
if (m_needPoints || m_showMetadata)
m_manager->execute();
else
m_manager->prepare();
dump(root);
}
root.add("pdal_version", pdal::GetFullVersionString());
return root;
}
示例14: 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;
}
示例15: loadMetadata
bool XMLSchema::loadMetadata(xmlNode *startNode, MetadataNode& input)
{
// Expect metadata in the following form
// We are going to skip the root element because we are
// expecting to be given one with our input
// <pc:metadata>
// <Metadata name="root" type="">
// <Metadata name="compression" type="string">lazperf</Metadata>
// <Metadata name="version" type="string">1.0</Metadata>
// </Metadata>
// </pc:metadata>
xmlNode *node = startNode;
for (node = startNode; node; node = node->next)
{
if (node->type != XML_ELEMENT_NODE)
continue;
if (std::string((const char*)node->name) == "Metadata")
{
const char *fieldname =
(const char*)xmlGetProp(node, (const xmlChar*)"name");
const char *etype =
(const char*)xmlGetProp(node, (const xmlChar*)"type");
const char *description =
(const char*)xmlGetProp(node, (const xmlChar*) "description");
const char *text = (const char*)xmlNodeGetContent(node);
if (!Utils::iequals(fieldname, "root"))
{
if (!fieldname)
{
std::cerr << "Unable to read metadata for node '" <<
(const char*)node->name << "' no \"name\" was given";
return false;
}
input.add(fieldname, text ? text : "",
description ? description : "");
}
}
loadMetadata(node->children, input);
}
return true;
}