Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to merge point cloud files whose names are specified in a text file #26

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}

}