From 2f12efb07df9893f076a747f12d74538fa2ec3f3 Mon Sep 17 00:00:00 2001 From: acornu Date: Mon, 1 Jun 2026 15:53:24 +0200 Subject: [PATCH] feat(API): add complementary args for ozcppexe --- middlewares/patch.js | 39 +++++++++++++-------------------------- regress/data/ozcpp.sh | 3 ++- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/middlewares/patch.js b/middlewares/patch.js index 90bbac2c..dba269ce 100644 --- a/middlewares/patch.js +++ b/middlewares/patch.js @@ -237,6 +237,9 @@ function ozCppExe(patches, outputDir, geojsonPath) { const arrArgsS = ['-s']; const arrArgsG = ['-g']; const arrArgsO = ['-or']; + const arrArgsRc = ['-rc']; + const arrArgsSc = ['-sc']; + const arrArgsOc = ['-orc']; patches.forEach((patch) => { arrArgsR.push(patch.withRgb ? patch.urlOpiRefRgb : patch.urlOpiRefIr); arrArgsS.push(patch.withRgb ? patch.urlOpiSecRgb : patch.urlOpiSecIr); @@ -246,8 +249,14 @@ function ozCppExe(patches, outputDir, geojsonPath) { } else { arrArgsO.push(patch.withOrig ? patch.urlOrthoIrOrig : patch.urlOrthoIr); } + if (patch.withRgb && patch.withIr) { + arrArgsRc.push(patch.urlOpiRefIr); + arrArgsSc.push(patch.urlOpiSecIr); + arrArgsOc.push(patch.withOrig ? patch.urlOrthoIrOrig : patch.urlOrthoIr); + } }); - const arrArgs = [...arrArgsR, ...arrArgsS, ...arrArgsG, ...arrArgsO, '-p', geojsonPath]; + const arrArgs = [...arrArgsR, ...arrArgsRc, ...arrArgsS, ...arrArgsSc, + ...arrArgsG, ...arrArgsO, ...arrArgsOc, '-p', geojsonPath]; const options = { weightDiffCost: 0.95, weightTransition: 10, @@ -279,19 +288,6 @@ function ozCppExe(patches, outputDir, geojsonPath) { }); } -// Maybe move that function to a specifique file.js file -// duplicate in regress\test-API\3_branch -function copyFileSync(source, target) { - let targetFile = target; - // If target is a directory, the copy will have the same name as the source - if (fs.existsSync(target)) { - if (fs.lstatSync(target).isDirectory()) { - targetFile = path.join(target, path.basename(source)); - } - } - fs.writeFileSync(targetFile, fs.readFileSync(source)); -} - async function applyPatch(pgClient, overviews, dirCache, idBranch, geojson) { const feature = geojson.features[0]; debug('applyPatch', feature); @@ -364,18 +360,9 @@ async function applyPatch(pgClient, overviews, dirCache, idBranch, geojson) { 'out_ortho', `out_${filename}_georef.tif`); } - if (patch.withIr && patch.withRgb) { - debug(' >>>> RGB + IR'); - console.warn('WARNING: Cache RGB + IR : le nouveau patch ne sera pas appliqué aux images IR'); - patch.urlOrthoIrOutput = path.join(dirCache, - 'ortho', patch.cogPath.dirPath, - `${idBranch}_${patch.cogPath.filename}_${newPatchNum}i.tif`); - const urlOrthoIr = patch.withOrig ? patch.urlOrthoIrOrig : patch.urlOrthoIr; - copyFileSync(urlOrthoIr, patch.urlOrthoIrOutput); - } - if (patch.withIr && !patch.withRgb) { - debug(' >>>> IR seul'); + if (patch.withIr) { + debug(' >>>> IR'); patch.urlOrthoIrOutput = path.join(urlOutputData, 'out_ortho', `out_${filename}i_georef.tif`); @@ -461,7 +448,7 @@ async function applyPatch(pgClient, overviews, dirCache, idBranch, geojson) { debug(' historique :', history); fs.writeFileSync(`${urlHistory}`, history); } else { - debug('history n\'existe pas encore'); + debug('le fichier \'history\' n\'existe pas encore'); const history = `orig;${newPatchNum}`; fs.writeFileSync(`${urlHistory}`, history); // On a pas besoin de renommer l'image d'origine diff --git a/regress/data/ozcpp.sh b/regress/data/ozcpp.sh index 7afa0314..84fdec6b 100755 --- a/regress/data/ozcpp.sh +++ b/regress/data/ozcpp.sh @@ -2,4 +2,5 @@ mkdir -p ./cache_test/cache_test_RGBIR/result_ozcpp_idBr10/out_graph mkdir -p ./cache_test/cache_test_RGBIR/result_ozcpp_idBr10/out_ortho cp ./cache_test/cache_test_RGBIR/graph/21/00/00/01/VN/6_AQ.tif ./cache_test/cache_test_RGBIR/result_ozcpp_idBr10/out_graph/out_10_AQ_georef.tif -cp ./cache_test/cache_test_RGBIR/ortho/21/00/00/01/VN/6_AQ.tif ./cache_test/cache_test_RGBIR/result_ozcpp_idBr10/out_ortho/out_10_AQ_georef.tif \ No newline at end of file +cp ./cache_test/cache_test_RGBIR/ortho/21/00/00/01/VN/6_AQ.tif ./cache_test/cache_test_RGBIR/result_ozcpp_idBr10/out_ortho/out_10_AQ_georef.tif +cp ./cache_test/cache_test_RGBIR/ortho/21/00/00/01/VN/6_AQi.tif ./cache_test/cache_test_RGBIR/result_ozcpp_idBr10/out_ortho/out_10_AQi_georef.tif \ No newline at end of file