kopia lustrzana https://github.com/OpenDroneMap/NodeODM
outputs field support for new tasks
rodzic
a6eb15c197
commit
39b8926824
12
index.js
12
index.js
|
@ -80,6 +80,12 @@ let server;
|
||||||
* required: false
|
* required: false
|
||||||
* type: string
|
* type: string
|
||||||
* -
|
* -
|
||||||
|
* name: outputs
|
||||||
|
* in: formData
|
||||||
|
* description: 'An optional serialized JSON string of paths relative to the project directory that should be included in the all.zip result file, overriding the default behavior.'
|
||||||
|
* required: false
|
||||||
|
* type: string
|
||||||
|
* -
|
||||||
* name: token
|
* name: token
|
||||||
* in: query
|
* in: query
|
||||||
* description: 'Token required for authentication (when authentication is required).'
|
* description: 'Token required for authentication (when authentication is required).'
|
||||||
|
@ -226,6 +232,12 @@ app.post('/task/new/commit/:uuid', authCheck, taskNew.getUUID, taskNew.handleCom
|
||||||
* required: false
|
* required: false
|
||||||
* type: string
|
* type: string
|
||||||
* -
|
* -
|
||||||
|
* name: outputs
|
||||||
|
* in: formData
|
||||||
|
* description: 'An optional serialized JSON string of paths relative to the project directory that should be included in the all.zip result file, overriding the default behavior.'
|
||||||
|
* required: false
|
||||||
|
* type: string
|
||||||
|
* -
|
||||||
* name: token
|
* name: token
|
||||||
* in: query
|
* in: query
|
||||||
* description: 'Token required for authentication (when authentication is required).'
|
* description: 'Token required for authentication (when authentication is required).'
|
||||||
|
|
47
libs/Task.js
47
libs/Task.js
|
@ -32,11 +32,12 @@ const Directories = require('./Directories');
|
||||||
const kill = require('tree-kill');
|
const kill = require('tree-kill');
|
||||||
const S3 = require('./S3');
|
const S3 = require('./S3');
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
|
const utils = require('./utils');
|
||||||
|
|
||||||
const statusCodes = require('./statusCodes');
|
const statusCodes = require('./statusCodes');
|
||||||
|
|
||||||
module.exports = class Task{
|
module.exports = class Task{
|
||||||
constructor(uuid, name, done, options = [], webhook = null, skipPostProcessing = false){
|
constructor(uuid, name, options = [], webhook = null, skipPostProcessing = false, outputs = [], done = () => {}){
|
||||||
assert(uuid !== undefined, "uuid must be set");
|
assert(uuid !== undefined, "uuid must be set");
|
||||||
assert(done !== undefined, "ready must be set");
|
assert(done !== undefined, "ready must be set");
|
||||||
|
|
||||||
|
@ -51,6 +52,7 @@ module.exports = class Task{
|
||||||
this.runningProcesses = [];
|
this.runningProcesses = [];
|
||||||
this.webhook = webhook;
|
this.webhook = webhook;
|
||||||
this.skipPostProcessing = skipPostProcessing;
|
this.skipPostProcessing = skipPostProcessing;
|
||||||
|
this.outputs = utils.parseUnsafePathsList(outputs);
|
||||||
|
|
||||||
async.series([
|
async.series([
|
||||||
// Read images info
|
// Read images info
|
||||||
|
@ -86,22 +88,28 @@ module.exports = class Task{
|
||||||
}
|
}
|
||||||
|
|
||||||
static CreateFromSerialized(taskJson, done){
|
static CreateFromSerialized(taskJson, done){
|
||||||
new Task(taskJson.uuid, taskJson.name, (err, task) => {
|
new Task(taskJson.uuid,
|
||||||
if (err) done(err);
|
taskJson.name,
|
||||||
else{
|
taskJson.options,
|
||||||
// Override default values with those
|
taskJson.webhook,
|
||||||
// provided in the taskJson
|
taskJson.skipPostProcessing,
|
||||||
for (let k in taskJson){
|
taskJson.outputs,
|
||||||
task[k] = taskJson[k];
|
(err, task) => {
|
||||||
}
|
if (err) done(err);
|
||||||
|
else{
|
||||||
|
// Override default values with those
|
||||||
|
// provided in the taskJson
|
||||||
|
for (let k in taskJson){
|
||||||
|
task[k] = taskJson[k];
|
||||||
|
}
|
||||||
|
|
||||||
// Tasks that were running should be put back to QUEUED state
|
// Tasks that were running should be put back to QUEUED state
|
||||||
if (task.status.code === statusCodes.RUNNING){
|
if (task.status.code === statusCodes.RUNNING){
|
||||||
task.status.code = statusCodes.QUEUED;
|
task.status.code = statusCodes.QUEUED;
|
||||||
|
}
|
||||||
|
done(null, task);
|
||||||
}
|
}
|
||||||
done(null, task);
|
});
|
||||||
}
|
|
||||||
}, taskJson.options, taskJson.webhook, taskJson.skipPostProcessing);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get path where images are stored for this task
|
// Get path where images are stored for this task
|
||||||
|
@ -317,6 +325,12 @@ module.exports = class Task{
|
||||||
'odm_georeferencing', 'odm_texturing',
|
'odm_georeferencing', 'odm_texturing',
|
||||||
'odm_dem/dsm.tif', 'odm_dem/dtm.tif', 'dsm_tiles', 'dtm_tiles',
|
'odm_dem/dsm.tif', 'odm_dem/dtm.tif', 'dsm_tiles', 'dtm_tiles',
|
||||||
'orthophoto_tiles', 'potree_pointcloud', 'images.json'];
|
'orthophoto_tiles', 'potree_pointcloud', 'images.json'];
|
||||||
|
|
||||||
|
// Did the user request different outputs than the default?
|
||||||
|
if (this.outputs.length > 0) allPaths = this.outputs;
|
||||||
|
|
||||||
|
console.log(allPaths);
|
||||||
|
|
||||||
let tasks = [];
|
let tasks = [];
|
||||||
|
|
||||||
if (config.test){
|
if (config.test){
|
||||||
|
@ -528,7 +542,8 @@ module.exports = class Task{
|
||||||
status: this.status,
|
status: this.status,
|
||||||
options: this.options,
|
options: this.options,
|
||||||
webhook: this.webhook,
|
webhook: this.webhook,
|
||||||
skipPostProcessing: !!this.skipPostProcessing
|
skipPostProcessing: !!this.skipPostProcessing,
|
||||||
|
outputs: this.outputs || []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -57,7 +57,7 @@ module.exports = {
|
||||||
// (num cores can be set programmatically, so can gcpFile, etc.)
|
// (num cores can be set programmatically, so can gcpFile, etc.)
|
||||||
if (["-h", "--project-path", "--cmvs-maxImages", "--time",
|
if (["-h", "--project-path", "--cmvs-maxImages", "--time",
|
||||||
"--zip-results", "--pmvs-num-cores",
|
"--zip-results", "--pmvs-num-cores",
|
||||||
"--start-with", "--gcp", "--end-with", "--images",
|
"--start-with", "--gcp", "--images",
|
||||||
"--rerun-all", "--rerun",
|
"--rerun-all", "--rerun",
|
||||||
"--slam-config", "--video", "--version", "name"].indexOf(option) !== -1) continue;
|
"--slam-config", "--video", "--version", "name"].indexOf(option) !== -1) continue;
|
||||||
|
|
||||||
|
|
|
@ -318,16 +318,18 @@ module.exports = {
|
||||||
|
|
||||||
// Create task
|
// Create task
|
||||||
cb => {
|
cb => {
|
||||||
new Task(req.id, req.body.name, (err, task) => {
|
new Task(req.id, req.body.name, req.body.options,
|
||||||
|
req.body.webhook,
|
||||||
|
req.body.skipPostProcessing === 'true',
|
||||||
|
req.body.outputs,
|
||||||
|
(err, task) => {
|
||||||
if (err) cb(err);
|
if (err) cb(err);
|
||||||
else {
|
else {
|
||||||
TaskManager.singleton().addNew(task);
|
TaskManager.singleton().addNew(task);
|
||||||
res.json({ uuid: req.id });
|
res.json({ uuid: req.id });
|
||||||
cb();
|
cb();
|
||||||
}
|
}
|
||||||
}, req.body.options,
|
});
|
||||||
req.body.webhook,
|
|
||||||
req.body.skipPostProcessing === 'true');
|
|
||||||
}
|
}
|
||||||
], err => {
|
], err => {
|
||||||
if (err) die(err.message);
|
if (err) die(err.message);
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
get: function(scope, prop, defaultValue){
|
get: function(scope, prop, defaultValue){
|
||||||
let parts = prop.split(".");
|
let parts = prop.split(".");
|
||||||
|
@ -18,5 +21,28 @@ module.exports = {
|
||||||
sanitize: function(filePath){
|
sanitize: function(filePath){
|
||||||
filePath = filePath.replace(/[^\w.-]/g, "_");
|
filePath = filePath.replace(/[^\w.-]/g, "_");
|
||||||
return filePath;
|
return filePath;
|
||||||
|
},
|
||||||
|
|
||||||
|
parseUnsafePathsList: function(paths){
|
||||||
|
// Parse a list (or a JSON encoded string representing a list)
|
||||||
|
// of paths and remove all traversals (., ..) and guarantee
|
||||||
|
// that the paths are relative
|
||||||
|
|
||||||
|
if (typeof paths === "string"){
|
||||||
|
try{
|
||||||
|
paths = JSON.parse(paths);
|
||||||
|
}catch(e){
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Array.isArray(paths)){
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return paths.map(p => {
|
||||||
|
const safeSuffix = path.normalize(p).replace(/^(\.\.(\/|\\|$))+/, '');
|
||||||
|
return path.join('./', safeSuffix);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "node-opendronemap",
|
"name": "node-opendronemap",
|
||||||
"version": "1.4.0",
|
"version": "1.5.0",
|
||||||
"description": "REST API to access ODM",
|
"description": "REST API to access ODM",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -69,6 +69,7 @@ $(function() {
|
||||||
formData.append("webhook", $("#webhook").val());
|
formData.append("webhook", $("#webhook").val());
|
||||||
formData.append("skipPostProcessing", !$("#doPostProcessing").prop('checked'));
|
formData.append("skipPostProcessing", !$("#doPostProcessing").prop('checked'));
|
||||||
formData.append("options", JSON.stringify(optionsModel.getUserOptions()));
|
formData.append("options", JSON.stringify(optionsModel.getUserOptions()));
|
||||||
|
// formData.append("outputs", JSON.stringify(['odm_orthophoto/odm_orthophoto.tif']));
|
||||||
|
|
||||||
if (this.mode() === 'file'){
|
if (this.mode() === 'file'){
|
||||||
if (this.filesCount() > 0){
|
if (this.filesCount() > 0){
|
||||||
|
|
Ładowanie…
Reference in New Issue