Skip to content

Commit

Permalink
add an option to merge command to read input point cloud files from a…
Browse files Browse the repository at this point in the history
… text file.
  • Loading branch information
alexbruy authored and wonder-sk committed Sep 25, 2023
1 parent 0bd0599 commit 0d784d3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ PDAL wrench has parallel processing built in and tries to run pipelines in paral
so PDAL wrench can split the input into multiple tiles that can be processed independently in parallel
- input dataset is a [virtual point cloud (VPC)](vpc-spec.md) - such datasets are composed of a number of files, so the whole work can be split into jobs
where each parallel job processes one or more input files

If the input is a single LAS/LAZ file, no parallelization is attempted. This may change in the future with introduction of more complex algorithms (where the cost of reading the input is much lower than the cost of the actual algorithm).

# Commands
Expand Down Expand Up @@ -113,6 +113,12 @@ Merges multiple point cloud files to a single one.
pdal_wrench merge --output=merged.las data1.las data2.las data3.las
```

Alternatively, it is possible to merge files whose paths are specified in a text file (one file per line)

```
pdal_wrench merge --output=merged.las --input-file-list=my_list.txt
```

## tile

Creates tiles from input data. For example to get tiles sized 100x100:
Expand Down
1 change: 1 addition & 0 deletions src/alg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ struct Merge : public Alg
// parameters from the user
std::string outputFile;
std::vector<std::string> inputFiles;
std::string inputFileList;

// args - initialized in addArgs()
pdal::Arg* argOutput = nullptr;
Expand Down
20 changes: 19 additions & 1 deletion src/merge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
****************************************************************************/

#include <iostream>
#include <fstream>
#include <filesystem>
#include <thread>

Expand All @@ -36,6 +37,8 @@ void Merge::addArgs()
argOutput = &programArgs.add("output,o", "Output virtual point cloud file", outputFile);
// we set hasSingleInput=false so the default "input,i" argument is not added
programArgs.add("files", "input files", inputFiles).setPositional();
programArgs.add("input-file-list", "Read input files from a text file", inputFileList);

}

bool Merge::checkArgs()
Expand Down Expand Up @@ -108,6 +111,22 @@ static std::unique_ptr<PipelineManager> pipeline(ParallelJobInfo *tile)
void Merge::preparePipelines(std::vector<std::unique_ptr<PipelineManager>>& pipelines)
{
ParallelJobInfo tile(ParallelJobInfo::Single, BOX2D(), filterExpression, filterBounds);
if (!inputFileList.empty())
{
std::ifstream inputFile(inputFileList);
std::string line;
if(!inputFile)
{
std::cerr << "failed to open input file list: " << inputFileList << std::endl;
return;
}

while (std::getline(inputFile, line))
{
inputFiles.push_back(line);
}
}

tile.inputFilenames = inputFiles;
tile.outputFilename = outputFile;

Expand All @@ -120,5 +139,4 @@ void Merge::preparePipelines(std::vector<std::unique_ptr<PipelineManager>>& pipe
QuickInfo qi = getQuickInfo(f);
totalPoints += qi.m_pointCount;
}

}

0 comments on commit 0d784d3

Please sign in to comment.