From d194361d9cf6c9019b3db5024890e646f9b01a77 Mon Sep 17 00:00:00 2001 From: Iris Jeuffrard Date: Fri, 10 Nov 2023 16:14:25 +0100 Subject: [PATCH 1/2] sendProject avec geometry --- middlewares/project.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/middlewares/project.js b/middlewares/project.js index fbcd461..b585431 100644 --- a/middlewares/project.js +++ b/middlewares/project.js @@ -45,11 +45,11 @@ async function insertProject(name, req) { return idProject; } -async function insertJob(name, command, idProject, tags, req) { +async function insertJob(name, command, idProject, tags, geometry, req) { debug(`Insertion du job ${name}`); let idJob; try { - const results = await req.client.query('INSERT INTO jobs (name, command, id_project, tags) VALUES ($1, $2, $3, $4) RETURNING id', [name, command, idProject, tags]); + const results = await req.client.query('INSERT INTO jobs (name, command, id_project, tags, geometry) VALUES ($1, $2, $3, $4, $5) RETURNING id', [name, command, idProject, tags, geometry]); idJob = results.rows[0].id; req.idJobs.push(idJob); } catch (error) { @@ -110,7 +110,7 @@ async function insertProjectFromJson(req, res, next) { for (const job of project.jobs) { /* eslint-disable no-await-in-loop */ const idJob = await insertJob(job.name, - job.command, idProject, job.tags ? job.tags : [], req); + job.command, idProject, job.tags ? job.tags : [], job.geometry, req); debug(`id_job = ${idJob}`); // Si il y a des dépendances entre les jobs if (job.deps) { From 8f105ea577add83deffb4cdee03fe283f1aa57fd Mon Sep 17 00:00:00 2001 From: Iris Jeuffrard Date: Mon, 20 Nov 2023 17:32:29 +0100 Subject: [PATCH 2/2] reproject geom to WGS84 --- middlewares/project.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middlewares/project.js b/middlewares/project.js index b585431..921af57 100644 --- a/middlewares/project.js +++ b/middlewares/project.js @@ -49,7 +49,7 @@ async function insertJob(name, command, idProject, tags, geometry, req) { debug(`Insertion du job ${name}`); let idJob; try { - const results = await req.client.query('INSERT INTO jobs (name, command, id_project, tags, geometry) VALUES ($1, $2, $3, $4, $5) RETURNING id', [name, command, idProject, tags, geometry]); + const results = await req.client.query('INSERT INTO jobs (name, command, id_project, tags, geometry) VALUES ($1, $2, $3, $4, ST_Transform($5, 4326)) RETURNING id', [name, command, idProject, tags, geometry]); idJob = results.rows[0].id; req.idJobs.push(idJob); } catch (error) {