Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 4 additions & 32 deletions gdal_processing.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@
}));
}

function processPatchAsync(patch, blocSize, isAuto) {
function processPolygonPatchAsync(patch, blocSize) {
// Appelée que dans le cas des saisies manuelles => Polygone
return new Promise((res, reject) => {
// On patch le graph
const { mask } = patch;
Expand All @@ -209,23 +210,7 @@
const urlGraph = patch.withOrig ? patch.urlGraphOrig : patch.urlGraph;
const urlOrthoRgb = patch.withOrig ? patch.urlOrthoRgbOrig : patch.urlOrthoRgb;
const urlOrthoIr = urlOrthoRgb.replace('.', 'i.');
const { urlOpiRefRgb, urlOpiSecRgb } = patch;
let urlOpiRefIr = urlOpiRefRgb;
const dnameRef = path.dirname(urlOpiRefIr);
let fnameRef = path.basename(urlOpiRefIr);
if (fnameRef.includes('_ix') === false) {
fnameRef = fnameRef.includes('x') ? fnameRef.replace('x', '_ix') : fnameRef.replace('.', 'i.');
urlOpiRefIr = path.join(dnameRef, fnameRef);
}
let urlOpiSecIr = urlOpiSecRgb;
if (isAuto) {
const dnameSec = path.dirname(urlOpiSecIr);
let fnameSec = path.basename(urlOpiSecIr);
if (fnameSec.includes('_ix') === false) {
fnameSec = fnameSec.includes('x') ? fnameSec.replace('x', '_ix') : fnameSec.replace('.', 'i.');
urlOpiSecIr = path.join(dnameSec, fnameSec);
}
}
const { urlOpiRefRgb, urlOpiRefIr } = patch;

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.

rgb avant Ref ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Je peux inversé mais ça va grossir la refactor car je vais devoir changer en amont et plus bas à tout les endroits qu'ils sont utilisé.

Je propose de le mettre dans la re-factorisation global, pour pas que la PR prennent trop de temps

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Celle parlé en réunion où j'ai une branche de re-factorisation sur laquelle j'applique ou vais appliquer les re-factorisations que l'on parle pendant les PR et les réunions, qui passera en plusieurs petites PR pour pas avoir un truc énorme quand les priorités sur les deux autres PR (#450 et #449) et la saisie de block seront fait


debug('chargement...');
Promise.all([
Expand All @@ -234,19 +219,14 @@
patch.withIr ? gdal.openAsync(urlOpiRefIr).then((ds) => getBand(ds)) : null,
patch.withRgb ? gdal.openAsync(urlOrthoRgb).then((ds) => getBands(ds)) : null,
patch.withIr ? gdal.openAsync(urlOrthoIr).then((ds) => getBand(ds)) : null,
(isAuto && patch.withRgb) ? gdal.openAsync(urlOpiSecRgb).then((ds) => getBands(ds)) : null,
(isAuto && patch.withIr) ? gdal.openAsync(urlOpiSecIr).then((ds) => getBand(ds)) : null,
]).then(async (images) => {
debug('... fin chargement');
debug('application du patch...');
// TODO: opi sec
const graph = images[0];
const opiRefRgb = images[1];
const opiRefIr = images[2];
const orthoRgb = images[3];
const orthoIr = images[4];
const opiSecRgb = (isAuto ? images[5] : 'none');
const opiSecIr = (isAuto ? images[6] : 'none');

graph.bands[0].forEach((_element, index) => {
/* eslint-disable no-param-reassign */
Expand Down Expand Up @@ -275,7 +255,7 @@
graph.srs.autoIdentifyEPSG();
} catch (err) {
const error = new Error(`gdal-async -> srs.autoIdentifyEPSG: ${err.message}`);
console.log(error);

Check warning on line 258 in gdal_processing.js

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
reject(error);
}
const graphMem = gdal.open('graph', 'w', 'MEM', graph.size.x, graph.size.y, 3);
Expand Down Expand Up @@ -325,14 +305,6 @@
if (opiRefIr) {
opiRefIr.ds.close();
}
if (isAuto) {
if (opiSecRgb) {
opiSecRgb.ds.close();
}
if (opiSecIr) {
opiSecIr.ds.close();
}
}

Promise.all([
gdal.drivers.get('COG').createCopyAsync(patch.urlGraphOutput, graphMem, {
Expand Down Expand Up @@ -364,4 +336,4 @@
exports.getTileEncoded = getTileEncoded;
exports.getColor = getColor;
exports.getDefaultEncoded = getDefaultEncoded;
exports.processPatchAsync = processPatchAsync;
exports.processPolygonPatchAsync = processPolygonPatchAsync;
3 changes: 1 addition & 2 deletions middlewares/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
(err, stdout) => {
debugOzcpp(stdout);
if (err) {
console.warn(err);

Check warning on line 273 in middlewares/patch.js

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
rej(err);
} else {
res(`${stdout} OK`);
Expand Down Expand Up @@ -366,7 +366,7 @@
}
if (patch.withIr && patch.withRgb) {
debug(' >>>> RGB + IR');
console.warn('WARNING: Cache RGB + IR : le nouveau patch ne sera pas appliqué aux images IR');

Check warning on line 369 in middlewares/patch.js

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
patch.urlOrthoIrOutput = path.join(dirCache,
'ortho', patch.cogPath.dirPath,
`${idBranch}_${patch.cogPath.filename}_${newPatchNum}i.tif`);
Expand Down Expand Up @@ -412,8 +412,7 @@
/* eslint-enable no-param-reassign */
slabsModified.push(patch.slab);

promises.push(gdalProcessing.processPatchAsync(patch, overviews.tileSize.width,
patchIsAuto));
promises.push(gdalProcessing.processPolygonPatchAsync(patch, overviews.tileSize.width));
});
}

Expand Down
Loading