//pdal库将las文件分割为多个文件
void dividerLAS()
{
using namespace pdal;
using namespace pdal::Dimension;
std::string in_filename = "F:\\pointCloud_data\\zhangjiang8\\pointcloud\\181013_030701-11-16-47-028.las";//中文路径可能报错
std::string fileName = "d:/out_#.las";
Options readerOps;
readerOps.add("filename", in_filename);
LasReader r;
r.setOptions(readerOps);
pdal::Options filterOps;
//filterOps.add("type", "filters.divider");
filterOps.add("capacity", 900000); //最大容量90万个点
//filterOps.add("count", 10); //将view分成10份
pdal::DividerFilter f;
f.setInput(r);
f.setOptions(filterOps);
PointTable table;
f.prepare(table);
pdal::PointViewSet s = f.execute(table);
Options xjOptions;
xjOptions.add("filename", fileName);
//double xoffset = 0.0, yoffset = 0.0, zoffset = 0.0;
//xjOptions.add("offset_x", xoffset);
//xjOptions.add("offset_y", yoffset);
//xjOptions.add("offset_z", zoffset);
//xjOptions.add("scale_x", 0.001);
//xjOptions.add("scale_y", 0.001);
//xjOptions.add("scale_z", 0.001);
pdal::PointTable table1;
table1.layout()->registerDim(Dimension::Id::X);
BufferReader xjBufferReader;
for (pdal::PointViewPtr v : s)
{
xjBufferReader.addView(v);
}
StageFactory factory;
Stage *writer = factory.createStage("writers.las");
writer->setInput(xjBufferReader);
writer->setOptions(xjOptions);
writer->prepare(table1);
writer->execute(table1);
}