diff --git a/helpers/odm_python.bat b/helpers/odm_python.bat new file mode 100644 index 0000000..165d6bf --- /dev/null +++ b/helpers/odm_python.bat @@ -0,0 +1,8 @@ +@echo off + +setlocal + +call %ODM_PATH%\win32env.bat +python %* + +endlocal \ No newline at end of file diff --git a/libs/Task.js b/libs/Task.js index 0429029..c45644c 100644 --- a/libs/Task.js +++ b/libs/Task.js @@ -19,12 +19,14 @@ along with this program. If not, see . const config = require('../config'); const async = require('async'); +const os = require('os'); const assert = require('assert'); const logger = require('./logger'); const fs = require('fs'); const path = require('path'); const rmdir = require('rimraf'); const odmRunner = require('./odmRunner'); +const odmInfo = require('./odmInfo'); const processRunner = require('./processRunner'); const Directories = require('./Directories'); const kill = require('tree-kill'); @@ -58,6 +60,26 @@ module.exports = class Task{ this.progress = 0; async.series([ + // Handle post-processing options logic + cb => { + // If we need to post process results + // if pc-ept is supported (build entwine point cloud) + // we automatically add the pc-ept option to the task options by default + if (skipPostProcessing) cb(); + else{ + odmInfo.supportsOption("pc-ept", (err, supported) => { + if (err){ + console.warn(`Cannot check for supported option pc-ept: ${err}`); + }else if (supported){ + if (!this.options.find(opt => opt.name === "pc-ept")){ + this.options.push({ name: 'pc-ept', value: true }); + } + } + cb(); + }); + } + }, + // Read images info cb => { fs.readdir(this.getImagesFolderPath(), (err, files) => { @@ -432,7 +454,15 @@ module.exports = class Task{ } - if (!this.skipPostProcessing) tasks.push(runPostProcessingScript()); + // postprocess.sh is still here for legacy/backward compatibility + // purposes, but we might remove it in the future. The new logic + // instructs the processing engine to do the necessary processing + // of outputs without post processing steps (build EPT). + // We're leaving it here only for Linux/docker setups, but will not + // be triggered on Windows. + if (os.platform() !== "win32" && !this.skipPostProcessing){ + tasks.push(runPostProcessingScript()); + } const taskOutputFile = path.join(this.getProjectFolderPath(), 'task_output.txt'); tasks.push(saveTaskOutput(taskOutputFile)); diff --git a/libs/odmInfo.js b/libs/odmInfo.js index 98b3a94..383e228 100644 --- a/libs/odmInfo.js +++ b/libs/odmInfo.js @@ -58,6 +58,15 @@ module.exports = { }); }, + supportsOption: function(optName, cb){ + this.getOptions((err, json) => { + if (err) cb(err); + else{ + cb(null, !!json.find(opt => opt.name === optName)); + } + }); + }, + getOptions: function(done){ if (odmOptions){ done(null, odmOptions); diff --git a/libs/odmRunner.js b/libs/odmRunner.js index 0cf662a..c49483e 100644 --- a/libs/odmRunner.js +++ b/libs/odmRunner.js @@ -17,6 +17,7 @@ along with this program. If not, see . */ "use strict"; let fs = require('fs'); +let os = require('os'); let path = require('path'); let assert = require('assert'); let spawn = require('child_process').spawn; @@ -28,8 +29,8 @@ module.exports = { run: function(options, projectName, done, outputReceived){ assert(projectName !== undefined, "projectName must be specified"); assert(options["project-path"] !== undefined, "project-path must be defined"); - - const command = path.join(config.odm_path, "run.sh"), + + const command = path.join(config.odm_path, os.platform() === "win32" ? "run.bat" : "run.sh"), params = []; for (var name in options){ @@ -123,6 +124,7 @@ module.exports = { // Launch const env = utils.clone(process.env); env.ODM_OPTIONS_TMP_FILE = utils.tmpPath(".json"); + env.ODM_PATH = config.odm_path; let childProcess = spawn(pythonExe, [path.join(__dirname, "..", "helpers", "odmOptionsToJson.py"), "--project-path", config.odm_path, "bogusname"], { env }); @@ -154,11 +156,15 @@ module.exports = { }) .on('error', handleResult); } - - // Try Python3 first - getOdmOptions("python3", (err, result) => { - if (err) getOdmOptions("python", done); - else done(null, result); - }); + + if (os.platform() === "win32"){ + getOdmOptions("helpers\\odm_python.bat", done); + }else{ + // Try Python3 first + getOdmOptions("python3", (err, result) => { + if (err) getOdmOptions("python", done); + else done(null, result); + }); + } } }; diff --git a/public/index.html b/public/index.html index b190336..d3046a6 100644 --- a/public/index.html +++ b/public/index.html @@ -37,6 +37,9 @@ background-color: #3d74d4; border-color: #4582ec; } + .task{ + background: white; + }