From 8ec5e06dadae66eb957f0620f54cc959e3704f78 Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Mon, 23 Oct 2023 09:26:21 +0300 Subject: [PATCH] add an option to read input data from a text file to tile command --- README.md | 8 +++++++- src/tile/tile.cpp | 20 +++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 37a5f3d..7daf22c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/tile/tile.cpp b/src/tile/tile.cpp index f4a3f70..9c0c37e 100644 --- a/src/tile/tile.cpp +++ b/src/tile/tile.cpp @@ -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; @@ -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); @@ -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; }