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

Adding option to build_vpc to read files from input file list #15

Merged
merged 2 commits into from
Jun 6, 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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,18 @@ To create a virtual point cloud:
pdal_wrench build_vpc --output=hello.vpc data1.las data2.las data3.las
```

Or, if the inputs are listed in a text file:
```
data1.las
data2.las
data3.las
```

You can provide that file as input:
```
pdal_wrench build_vpc --output=hello.vpc --input-file-list=inputs.txt
```

Afterwards, other algorithms can be applied to a VPC:
```
pdal_wrench clip --input=hello.vpc --polygon=clip.gpkg --output=hello_clipped.vpc
Expand Down
32 changes: 31 additions & 1 deletion src/vpc.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>
namespace fs = std::filesystem;
Expand All @@ -25,7 +26,6 @@ namespace fs = std::filesystem;
#include "nlohmann/json.hpp"



using json = nlohmann::json;

using namespace pdal;
Expand Down Expand Up @@ -395,16 +395,20 @@ std::string dateTimeStringFromYearAndDay(int year, int dayOfYear)
void buildVpc(std::vector<std::string> args)
{
std::string outputFile;
std::string inputFileList;
std::vector<std::string> inputFiles;
bool boundaries = false;
bool stats = false;
bool overview = false;
int max_threads = -1;
bool verbose = false;
bool help = false;

ProgramArgs programArgs;
programArgs.add("help,h", "Output command help.", help);
programArgs.add("output,o", "Output virtual point cloud file", outputFile);
programArgs.add("files,f", "input files", inputFiles).setPositional();
programArgs.add("input-file-list", "Read input files from a txt file, one file per line.", inputFileList);
programArgs.add("boundary", "Calculate boundary polygons from data", boundaries);
programArgs.add("stats", "Calculate statistics from data", stats);
programArgs.add("overview", "Create overview point cloud from source data", overview);
Expand All @@ -422,6 +426,32 @@ void buildVpc(std::vector<std::string> args)
return;
}

if (help)
{

std::cout << "usage: pdal_wrench build_vpc [<args>]" << std::endl;
programArgs.dump(std::cerr, 2, Utils::screenWidth());
return;
}

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);
}

}

// std::cout << "input " << inputFiles.size() << std::endl;
// std::cout << "output " << outputFile << std::endl;

Expand Down