MetadataNode InfoKernel::dumpQuery(PointViewPtr inView) const { int count; std::string location; // See if there's a provided point count. StringList parts = Utils::split2(m_queryPoint, '/'); if (parts.size() == 2) { location = parts[0]; count = atoi(parts[1].c_str()); } else if (parts.size() == 1) { location = parts[0]; count = inView->size(); } else count = 0; if (count == 0) throw pdal_error("Invalid location specificiation. " "--query=\"X,Y[/count]\""); auto seps = [](char c){ return (c == ',' || c == '|' || c == ' '); }; std::vector<std::string> tokens = Utils::split2(location, seps); std::vector<double> values; for (auto ti = tokens.begin(); ti != tokens.end(); ++ti) { double d; if (Utils::fromString(*ti, d)) values.push_back(d); } if (values.size() != 2 && values.size() != 3) throw pdal_error("--points must be two or three values"); PointViewPtr outView = inView->makeNew(); std::vector<PointId> ids; if (values.size() >= 3) { KD3Index kdi(*inView); kdi.build(); ids = kdi.neighbors(values[0], values[1], values[2], count); } else { KD2Index kdi(*inView); kdi.build(); ids = kdi.neighbors(values[0], values[1], count); } for (auto i = ids.begin(); i != ids.end(); ++i) outView->appendPoint(*inView.get(), *i); return outView->toMetadata(); }
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; }