diff --git a/libs/Task.js b/libs/Task.js index 44fa597..0208281 100644 --- a/libs/Task.js +++ b/libs/Task.js @@ -328,6 +328,15 @@ module.exports = class Task{ }; }; + const pdalTranslate = (inputPath, outputPath) => { + return (done) => { + this.runningProcesses.push(processRunner.runPdalTranslate({ + inputFile: inputPath, + outputFile: outputPath + }, handleProcessExit(done), handleOutput)); + }; + }; + // All paths are relative to the project directory (./data//) let allFolders = ['odm_orthophoto', 'odm_georeferencing', 'odm_texturing', 'odm_meshing', 'orthophoto_tiles', 'potree_pointcloud']; @@ -340,11 +349,28 @@ module.exports = class Task{ }); } - async.series([ - generateTiles(path.join('odm_orthophoto', 'odm_orthophoto.tif'), 'orthophoto_tiles'), - generatePotreeCloud(path.join('odm_georeferencing', 'odm_georeferenced_model.ply.las'), 'potree_pointcloud'), + let orthophotoPath = path.join('odm_orthophoto', 'odm_orthophoto.tif'), + lasPointCloudPath = path.join('odm_georeferencing', 'odm_georeferenced_model.ply.las'), + projectFolderPath = this.getProjectFolderPath(); + + let commands = [ + generateTiles(orthophotoPath, 'orthophoto_tiles'), + generatePotreeCloud(lasPointCloudPath, 'potree_pointcloud'), createZipArchive('all.zip', allFolders) - ], (err) => { + ]; + + // If point cloud file does not exist, it's likely because location (GPS/GPC) information + // was missing and the file was not generated. + let fullLasPointCloudPath = path.join(projectFolderPath, lasPointCloudPath); + if (!fs.existsSync(fullLasPointCloudPath)){ + let unreferencedPointCloudPath = path.join(projectFolderPath, "opensfm", "depthmaps", "merged.ply"); + if (fs.existsSync(unreferencedPointCloudPath)){ + logger.info(`${lasPointCloudPath} is missing, will attempt to generate it from ${unreferencedPointCloudPath}`); + commands.unshift(pdalTranslate(unreferencedPointCloudPath, fullLasPointCloudPath)); + } + } + + async.series(commands, (err) => { if (!err){ this.setStatus(statusCodes.COMPLETED); finished(); diff --git a/libs/processRunner.js b/libs/processRunner.js index fb94aa9..69d66aa 100644 --- a/libs/processRunner.js +++ b/libs/processRunner.js @@ -89,5 +89,13 @@ module.exports = { "-o", options.outputDir]; }, ["inputFile", "outputDir"], - path.join("..", "tests", "potree_output.txt")) + path.join("..", "tests", "potree_output.txt")), + + runPdalTranslate: makeRunner("/code/SuperBuild/build/pdal/bin/pdal", + function(options){ + return ["translate", + "-i", options.inputFile, + "-o", options.outputFile]; + }, + ["inputFile", "outputFile"]) };