Skip to content

Commit

Permalink
orthophoto crop debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Erfan-Shooraj committed Apr 5, 2023
1 parent d0b92c2 commit 8b80576
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,10 @@ app.get('/crop', function(req, res, next) {
month: "numeric",
day: "numeric",
})}.zip`
var zipName = zipName.replace(/[/\\?%*:|"<>]/g, ' ').slice(0,256);
.replace(/[/\\?%*:|"<>]/g, ' ')
.slice(0,256)
.trim();

if (zipName.slice(zipName.length-4).toLowerCase() !=".zip") {
zipName = zipName.slice(0,252);
zipName += ".zip";
Expand Down Expand Up @@ -725,6 +728,8 @@ app.get('/crop', function(req, res, next) {
if (!fs.existsSync(path.join(os.tmpdir(), 'exports', project, task, uuid))) {
fs.mkdirSync(path.join(os.tmpdir(), 'exports', project, task, uuid));
}
var polygonGeoJSONPath = path.join(os.tmpdir(), 'exports', project, task, uuid, `crop.bounds.geojson`);

if (importToWebODM) {
if (type=="ept"){
if (!fs.existsSync(path.join(os.tmpdir(), 'exports', project, task, uuid, "georeferenced_model"))) {
Expand All @@ -747,8 +752,6 @@ app.get('/crop', function(req, res, next) {
}
var fileDir=path.join(os.tmpdir(), 'exports', project, task, uuid, dir);
var filePath = `${path.join(os.tmpdir(), 'exports', project, task, uuid, dir, file)}`;

var polygonGeoJSONPath = path.join(os.tmpdir(), 'exports', project, task, uuid, `crop.bounds.geojson`);
}
} else {
var filePath = `${path.join(os.tmpdir(), 'exports', project, task, uuid, fileName)}`;
Expand Down Expand Up @@ -783,6 +786,8 @@ app.get('/crop', function(req, res, next) {
var polygonPath = path.join(os.tmpdir(), 'exports', project, uuid, `polygon.csv`);
var polygonShpPath = path.join(os.tmpdir(), 'exports', project, uuid, `polygon.shp`);
}

var polygonGeoJSONPath = path.join(os.tmpdir(), 'exports', project, uuid, `crop.bounds.geojson`);
}
filesDirs.push(filesDir);

Expand Down Expand Up @@ -917,6 +922,7 @@ app.get('/crop', function(req, res, next) {
var dlProc = exec(`curl ${url} --output ${dlFilePath} --header "cookie:${req.headers.cookie}"`,(error, stdout, stderr)=>{
if (error) {
console.error(`exec error: ${error}`);
reject();
}
console.log(`stdout: ${stdout}`);
console.error(`stderr: ${stderr}`);
Expand Down Expand Up @@ -1067,7 +1073,8 @@ app.get('/crop', function(req, res, next) {
})
}
})
}).catch(()=>{
}).catch((e)=>{
console.log(e)
res.status(500).send("An error occured during the export process");
})

Expand Down

0 comments on commit 8b80576

Please sign in to comment.