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

add an option to read input data from a text file to tile command #29

Merged
merged 3 commits into from
Oct 23, 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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ Creates tiles from input data. For example to get tiles sized 100x100:
pdal_wrench tile --length=100 --output=/data/tiles data1.las data2.las data3.las
```

This tool can also read input data from a text file (one file per line)

```
pdal_wrench tile --length=100 --output=/data/tiles --input-file-list=my_list.txt
```

## thin

Creates a thinned version of the point cloud by only keeping every N-th point (`every-nth` mode) or keep points based on their distance (`sample` mode).
Expand Down
20 changes: 19 additions & 1 deletion src/tile/tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ struct BaseInfo
int max_threads;
std::string outputFormat; // las or laz (for now)
bool buildVpc = false;
std::string inputFileList; // file list with input files
} opts;

pdal::BOX3D trueBounds;
Expand Down Expand Up @@ -434,6 +435,7 @@ void addArgs(pdal::ProgramArgs& programArgs, BaseInfo::Options& options, pdal::A
{
programArgs.add("output,o", "Output directory/filename", options.outputDir);
programArgs.add("files,i", "Input files/directory", options.inputFiles).setPositional();
programArgs.add("input-file-list", "Read input files from a text file", options.inputFileList);
programArgs.add("length,l", "Tile length", options.tileLength, 1000.);
tempArg = &(programArgs.add("temp_dir", "Temp directory", options.tempDir));
programArgs.add("output-format", "Output format (las/laz)", options.outputFormat);
Expand Down Expand Up @@ -461,7 +463,7 @@ bool handleOptions(pdal::StringList& arglist, BaseInfo::Options& options)
addArgs(programArgs, options, tempArg, threadsArg);
try
{
programArgs.parse(arglist);
programArgs.parseSimple(arglist);
}
catch (const pdal::arg_error& err)
{
Expand Down Expand Up @@ -498,6 +500,22 @@ bool handleOptions(pdal::StringList& arglist, BaseInfo::Options& options)
throw FatalError("Unknown output format: " + options.outputFormat);
}

if (!options.inputFileList.empty())
{
std::ifstream inputFile(options.inputFileList);
std::string line;
if(!inputFile)
{
throw FatalError("Failed to open input file list: " + options.inputFileList);
}

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


return true;
}

Expand Down