diff --git a/external/pdal_wrench/alg.cpp b/external/pdal_wrench/alg.cpp index 7a92bc09f6e..7da639625e8 100644 --- a/external/pdal_wrench/alg.cpp +++ b/external/pdal_wrench/alg.cpp @@ -173,3 +173,15 @@ void removeFiles(const std::vector &tileOutputFiles, bool removePar fs::remove(outputDir); } } + +fs::path fileStem(const std::string &filename) +{ + fs::path inputBasename = fs::path(filename).stem(); + + while(inputBasename.has_extension()) + { + inputBasename = inputBasename.stem(); + } + + return inputBasename; +} \ No newline at end of file diff --git a/external/pdal_wrench/alg.hpp b/external/pdal_wrench/alg.hpp index 441dc457908..2f311a468fc 100644 --- a/external/pdal_wrench/alg.hpp +++ b/external/pdal_wrench/alg.hpp @@ -93,6 +93,8 @@ bool runAlg(std::vector args, Alg &alg); void removeFiles(const std::vector &tileOutputFiles, bool removeParentDirIfEmpty = true); +fs::path fileStem(const std::string &filename); + ////////////// diff --git a/external/pdal_wrench/clip.cpp b/external/pdal_wrench/clip.cpp index 04ec8fd2845..300f8841b75 100644 --- a/external/pdal_wrench/clip.cpp +++ b/external/pdal_wrench/clip.cpp @@ -191,7 +191,7 @@ void Clip::preparePipelines(std::vector>& pipel // for input file /x/y/z.las that goes to /tmp/hello.vpc, // individual output file will be called /tmp/hello/z.las - fs::path inputBasename = fs::path(f.filename).stem(); + fs::path inputBasename = fileStem(f.filename); // if the output is not VPC las file format is forced to avoid time spent on compression, files will be later merged into single output and removed anyways if (!ends_with(outputFile, ".vpc")) diff --git a/external/pdal_wrench/merge.cpp b/external/pdal_wrench/merge.cpp index 2b767ea76b6..64e4e58be76 100644 --- a/external/pdal_wrench/merge.cpp +++ b/external/pdal_wrench/merge.cpp @@ -99,6 +99,18 @@ static std::unique_ptr pipeline(ParallelJobInfo *tile) last.push_back(filterExpr); } + // this is a special case for merging COPC files + // writers.copc does not support multiple inputs + // merge step is necessary before writing the output + if (ends_with(tile->outputFilename, ".copc.laz")) + { + Stage *merge = &manager->makeFilter("filters.merge"); + for (Stage *stage : last) + merge->setInput(*stage); + last.clear(); + last.push_back(merge); + } + pdal::Options options; options.add(pdal::Option("forward", "all")); Stage* writer = &manager->makeWriter(tile->outputFilename, "", options); @@ -138,8 +150,10 @@ void Merge::preparePipelines(std::vector>& pipe VirtualPointCloud vpc; if (!vpc.read(inputFile)) + { std::cerr << "could not open input VPC: " << inputFile << std::endl; return; + } for (const VirtualPointCloud::File& vpcSingleFile : vpc.files) { diff --git a/external/pdal_wrench/thin.cpp b/external/pdal_wrench/thin.cpp index 23e8c2907af..2b5a3644fa2 100644 --- a/external/pdal_wrench/thin.cpp +++ b/external/pdal_wrench/thin.cpp @@ -167,7 +167,7 @@ void Thin::preparePipelines(std::vector>& pipel // for input file /x/y/z.las that goes to /tmp/hello.vpc, // individual output file will be called /tmp/hello/z.las - fs::path inputBasename = fs::path(f.filename).stem(); + fs::path inputBasename = fileStem(f.filename); if (!ends_with(outputFile, ".vpc")) tile.outputFilename = (outputSubdir / inputBasename).string() + ".las"; diff --git a/external/pdal_wrench/to_vector.cpp b/external/pdal_wrench/to_vector.cpp index 5ac8ae0a651..3bdd82b45e0 100644 --- a/external/pdal_wrench/to_vector.cpp +++ b/external/pdal_wrench/to_vector.cpp @@ -112,7 +112,7 @@ void ToVector::preparePipelines(std::vector>& p // for input file /x/y/z.las that goes to /tmp/hello.vpc, // individual output file will be called /tmp/hello/z.las - fs::path inputBasename = fs::path(f.filename).stem(); + fs::path inputBasename = fileStem(f.filename); tile.outputFilename = (outputSubdir / inputBasename).string() + ".gpkg"; tileOutputFiles.push_back(tile.outputFilename); diff --git a/external/pdal_wrench/translate.cpp b/external/pdal_wrench/translate.cpp index 62ce15d0619..2d92948d172 100644 --- a/external/pdal_wrench/translate.cpp +++ b/external/pdal_wrench/translate.cpp @@ -169,12 +169,12 @@ void Translate::preparePipelines(std::vector>& // for input file /x/y/z.las that goes to /tmp/hello.vpc, // individual output file will be called /tmp/hello/z.las - fs::path inputBasename = fs::path(f.filename).stem(); + fs::path inputBasename = fileStem(f.filename); if (!ends_with(outputFile, ".vpc")) tile.outputFilename = (outputSubdir / inputBasename).string() + ".las"; else - tile.outputFilename = (outputSubdir / inputBasename).string() + outputFormat; + tile.outputFilename = (outputSubdir / inputBasename).string() + "." + outputFormat; tileOutputFiles.push_back(tile.outputFilename);