@@ -306,7 +306,7 @@ void geometryToJson(const Geometry &geom, const BOX3D &bbox, nlohmann::json &jso
306306 }
307307}
308308
309- bool VirtualPointCloud::write (std::string filename, bool forceAbsolutePaths )
309+ bool VirtualPointCloud::write (std::string filename)
310310{
311311 if (!isVpcFilename (filename))
312312 filename += " .vpz" ;
@@ -319,6 +319,38 @@ bool VirtualPointCloud::write(std::string filename, bool forceAbsolutePaths)
319319
320320 fs::path outputPath = fs::path (filenameAbsolute).parent_path ();
321321
322+ bool forceAbsolutePaths = false ;
323+ for (const File &f : files)
324+ {
325+ fs::path fRelative = fs::relative (f.filename , outputPath);
326+ if (fRelative .empty ()) {
327+ forceAbsolutePaths = true ;
328+ std::cerr << " Warning: failed to make filename relative to output path: "
329+ << f.filename
330+ << " ; using absolute paths in the output VPC file"
331+ << std::endl;
332+ break ;
333+ }
334+
335+ for (size_t i = 0 ; i < f.overviewFilenames .size (); ++i)
336+ {
337+ std::string ovFilename (f.overviewFilenames [i]);
338+ if (!pdal::Utils::isRemote (ovFilename))
339+ {
340+ const fs::path fRelative = fs::relative (ovFilename, outputPath);
341+ if (fRelative .empty ())
342+ {
343+ forceAbsolutePaths = true ;
344+ std::cerr << " Warning: failed to make overview filename relative to output path: "
345+ << ovFilename
346+ << " ; using absolute paths in the output VPC file"
347+ << std::endl;
348+ break ;
349+ }
350+ }
351+ }
352+ }
353+
322354 std::vector<nlohmann::ordered_json> jFiles;
323355 for ( const File &f : files )
324356 {
@@ -580,7 +612,6 @@ void buildVpc(std::vector<std::string> args)
580612 int max_threads = -1 ;
581613 bool verbose = false ;
582614 bool help = false ;
583- bool forceAbsolutePaths = false ;
584615
585616 ProgramArgs programArgs;
586617 programArgs.add (" help,h" , " Output command help." , help);
@@ -596,7 +627,6 @@ void buildVpc(std::vector<std::string> args)
596627
597628 pdal::Arg& argThreads = programArgs.add (" threads" , " Max number of concurrent threads for parallel runs" , max_threads);
598629 programArgs.add (" verbose" , " Print extra debugging output" , verbose);
599- programArgs.add (" use-absolute-paths" , " Store absolute file paths instead of relative paths in the output VPC" , forceAbsolutePaths);
600630
601631 try
602632 {
@@ -970,7 +1000,7 @@ void buildVpc(std::vector<std::string> args)
9701000 }
9711001 }
9721002
973- vpc.write (outputFile, forceAbsolutePaths );
1003+ vpc.write (outputFile);
9741004
9751005 // TODO: for now hoping that all files have the same file type + CRS + point format + scaling
9761006 // "dataformat_id"
0 commit comments