Skip to content

Commit

Permalink
add an option to read input data from a text file to tile command
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Oct 23, 2023
1 parent 0d784d3 commit 8ec5e06
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,13 @@ pdal_wrench merge --output=merged.las --input-file-list=my_list.txt
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
pdal_wrench tile --length=100 --output=/data/tiles --files=data1.las --files=data2.las --files=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
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 @@ -433,7 +434,8 @@ static void writeOutputFile(const std::string& filename, pdal::PointViewPtr view
void addArgs(pdal::ProgramArgs& programArgs, BaseInfo::Options& options, pdal::Arg * &tempArg, pdal::Arg * &threadsArg)
{
programArgs.add("output,o", "Output directory/filename", options.outputDir);
programArgs.add("files,i", "Input files/directory", options.inputFiles).setPositional();
programArgs.add("files,i", "Input files/directory", options.inputFiles);
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 @@ -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 8ec5e06

Please sign in to comment.