Skip to content

Commit

Permalink
add an option to read input data from a text file to tile command (#29)
Browse files Browse the repository at this point in the history
* add an option to read input data from a text file to tile command

* use parseSimple() o instead of parse() as we don't need validation of
mandatory parameters

* update README
  • Loading branch information
alexbruy authored Oct 23, 2023
1 parent 0d784d3 commit 43caeb9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
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

0 comments on commit 43caeb9

Please sign in to comment.