Skip to content

Refactor on applyPatch to prepare for multi-patch#453

Open
ACornuIGN wants to merge 2 commits into
ign-packo:2Opifrom
ACornuIGN:refactor_applyPatch
Open

Refactor on applyPatch to prepare for multi-patch#453
ACornuIGN wants to merge 2 commits into
ign-packo:2Opifrom
ACornuIGN:refactor_applyPatch

Conversation

@ACornuIGN

Copy link
Copy Markdown
Collaborator

Re-factorisation de applyPatch en plusieurs petites fonctions pour une meilleure compréhension de la fonction et pour la préparation au passage au multi patch

Re-factorisation de insertPatch dans db.js pour une requête plus robuste et pour réduire le nombre de requête de l'api vers la base de données

@ACornuIGN ACornuIGN requested a review from ftoromanoff June 23, 2026 07:30
@ACornuIGN ACornuIGN added wip Travail en cours (ne pas merger) and removed wip Travail en cours (ne pas merger) labels Jun 23, 2026
Comment thread middlewares/patch.js
Comment on lines +449 to +470
promisesCreatePatch.push(createPatch(aCog,
feature,
feature.properties.color,
feature.properties.opiName,
patchIsAuto ? feature.properties.colorSec : null,
patchIsAuto ? feature.properties.opiNameSec : null,
opi.with_rgb,
opi.with_ir,
overviews,
dirCache,
idBranch,
patchIsAuto));
});
debug('~Promise.all');
const patchOnCogs = await Promise.all(promisesCreatePatch);
debug('~process patch');

if (feature.properties.is_auto) {
await processSemiAutoPatch(dirCache, idBranch, patchOnCogs, geojsonPath);
} else {
await processPolygonPatch(dirCache, overviews, idBranch, patchOnCogs, newPatchNum);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pour des raisons de rapidité, limiter le nombre d'await en essayant de chainer les promesses.

Comment thread middlewares/patch.js
debug('~~Semi-auto patch');
const urlOutputData = `${dirCache}/result_ozcpp_idBr${idBranch}`;
dirTmp = urlOutputData;
await ozCppExe(patchOnCogs, urlOutputData, geojsonPath);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pourquoi faire un await ici, sachatn que l'in fait un autre await a l'appel de cette fonction. (mettre return a la place)

Comment thread middlewares/patch.js
'--verbose',
);
return new Promise((res, rej) => {
execFile(ozExe, arrArgs, { env: { PROJ_LIB: process.env.PROJ_LIB } },

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Est ce toujours utile que execFile soit encapsulé dans une promesse ?

Comment thread middlewares/patch.js
patches.forEach((patch) => {
}

async function renameCogs(pgClient, dirCache, idBranch, patchOnCogs, patchId, newPatchNum) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A retravailler. La fonction ne fais pas ce que son nom indique. (Sortir le forEach et renameCog())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants