Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8776325
feat(itowns): add Select 2nd OPI
ftoromanoff Jul 7, 2025
4fd860c
feat(itowns): add function saisie to add polyline
ftoromanoff Jul 7, 2025
f73f00a
feat(API): create route for cpp exe
amrosu Jun 6, 2024
4b7e77a
docs(API): create route for cpp exe in swagger
amrosu Jun 14, 2024
f1442ee
refactor(API): rename export processPatch -> processPatchAsync
amrosu Aug 7, 2024
8363a15
fix(API,monitor): post patch error
amrosu Aug 7, 2024
c269f65
feat(db): new structure with opi_sec & is_auto
amrosu Aug 26, 2024
d4c4038
feat(API): init add sec opi & auto patch
ftoromanoff Jul 8, 2025
493044b
docs: init update readme
amrosu Aug 20, 2024
d5ea6c9
refactor(API,docs): adapt cppexe route for inputs as lists
amrosu Nov 6, 2024
bc1ade3
feat(API,docs): adapt cppexe route for equiv opi & param wt
amrosu Jul 18, 2025
c47b51c
refactor(monitor): type of saisie as Dico
ftoromanoff Jul 8, 2025
ffec8d9
feat(monitor): GUI -> change size of button coloring
ftoromanoff Jul 9, 2025
7a461f3
feat(Editing): color of edit buttons
ftoromanoff Jul 17, 2025
c054ef4
fix(monitor): gestion of error.message
ftoromanoff Jul 17, 2025
18837a1
fix(monitor): LineString and last point
ftoromanoff Jul 30, 2025
d0054e1
monitor(GUI): fix checkbox opi.visible
ftoromanoff Aug 1, 2025
57ffd23
refactor(monitor): change patch labels
ftoromanoff Aug 6, 2025
a2d9a03
refactor(api&monitor): change structure of geojon for patches
ftoromanoff Jul 17, 2025
86c11c6
debut fix tests
ftoromanoff Jul 9, 2025
346d0a3
refactor(wmts): add message if error
ftoromanoff Aug 5, 2025
9880aeb
fix(middlewares/patch): remove .then() when using await
ftoromanoff Jul 18, 2025
dd66cc0
refactor(middlewares/patch): rename var P as patchData (maybe slabMet…
ftoromanoff Jul 30, 2025
1fa33cf
refactor(api): in gdal_processing move functions to root
ftoromanoff Aug 6, 2025
4410c27
refactor(api): move function to write geojsonfile to geojson.js from …
ftoromanoff Aug 7, 2025
f01431a
feat(api:middlewares/patch): add semi auto patch with ozcpp.exe
ftoromanoff Jul 30, 2025
2ef115b
fix(api): fix PROJ_LIB envvar for gdal_processing
ftoromanoff Aug 7, 2025
c83d85d
fix(api): cppexe -> ortho with all opi in graph
ftoromanoff Aug 8, 2025
5aa93a9
docs: remove no longer needed info on PROJ_LIB
amrosu Sep 25, 2025
d0b202a
docs(qview): init change macro for patch auto
amrosu Oct 1, 2025
0f26633
fix: set correct identifier in ressources files
amrosu Oct 7, 2025
e979a9f
fix(monitor): change error user message when there is an API error
ACornuIGN Oct 8, 2025
a435a66
Merge pull request #442 from ACornuIGN/fix_undifined_ms
amrosu Nov 26, 2025
bfea496
refactor(API): change output dir name
amrosu Jan 28, 2026
de552dc
refactor(API): clean up cpp output dir
amrosu Jan 28, 2026
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
15 changes: 3 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,6 @@ par défaut :

La doc de l'API est publiée directement par le service et est disponible à l'adresse : http://[serveur]:[port]/doc

Attention, l'API utilise une version de GDAL pour la lecture et la création des images du cache. Si une version de GDAL est déjà présente sur la machine, il peut y avoir des problèmes avec la variable d'environnement **PROJ_LIB** qui indique l'emplacement du dossier qui contient la définition des systèmes de coordonnées. Dans ce cas, l'API va signaler une erreur lors de l'application d'une retouche (erreur visible dans la console côté serveur et dans l'interface iTowns côté client). Si cela se produit, il faut supprimer la variable d'environnement **PROJ_LIB** avant de lancer l'API.
Sous MacOS ou Linux, cela peut être fait avec la commande :
```
unset PROJ_LIB
```
Sous Windows :
```
SET PROJ_LIB=
```


### Principe de fonctionnement

Ce service propose:
Expand Down Expand Up @@ -585,8 +574,10 @@ optional arguments:
## Raccourcis clavier

Les raccourcis clavier disponibles dans l'interface sont :
- Sélectionner une OPI (*Select an OPI*) : **s**
- Sélectionner une OPI de réference (*Select ref OPI*) : **s**
- Sélectionner une OPI secondaire (*Select sec OPI*) : **w**
- Démarrer polygone (*Start polygon*) : **p**
- Démarrer polygone pour saisie auto (*Start polygon auto*) : **t**
- Annuler polygone (*Undo*) : **Ctrl + Z**
- Refaire polygone (*Redo*) : **Ctrl + Y**
- Masquer/Afficher l’Ortho mosaïquée : **m**
Expand Down
39 changes: 33 additions & 6 deletions db/db.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const debug = require('debug')('db');
const format = require('pg-format');
// const fs = require('fs');
// const gjson = require('./geojson');

async function beginTransaction(pgClient) {
debug('BEGIN');
Expand Down Expand Up @@ -180,7 +182,7 @@ async function getOPIFromColor(pgClient, idBranch, color) {
}

async function getOPIFromName(pgClient, idBranch, name) {
debug(` ~~getOpiId (name: ${name})`);
debug(` ~~getOPIFromName (name: ${name})`);
const results = await pgClient.query(
'SELECT o.name, to_char(o.date,\'YYYY-mm-dd\') as date, o.time_ut, o.color, o.id, o.with_rgb, o.with_ir FROM opi o, branches b WHERE b.id_cache = o.id_cache AND b.id = $1 AND o.name=$2',
[idBranch, name],
Expand All @@ -192,19 +194,43 @@ async function getOPIFromName(pgClient, idBranch, name) {
return results.rows[0];
}

async function insertPatch(pgClient, idBranch, geometry, opiId) {
debug(` ~~insertPatch (idBranch: ${idBranch})`);
// async function getOPIFromId(pgClient, idOpi) {
// debug(` ~~getOPIFromId (idOpi: ${idOpi})`);
// const results = await pgClient.query(
// 'SELECT name, to_char(date,\'YYYY-mm-dd\'), time_ut, color,'
// + 'with_rgb, with_ir FROM opi WHERE id=$1',
// [idOpi],
// );
// if (results.rowCount !== 1) {
// throw new Error(`on a trouvé ${results.rowCount} opi pour le idOpi '${idOpi}'`);
// }
// return results.rows[0];
// }

async function getCacheCrsFromIdBranch(pgClient, idBranch) {
debug(` ~~getCacheCrs (idBranch: ${idBranch})`);
const results = await pgClient.query('SELECT crs FROM caches WHERE id=(SELECT id_cache FROM branches WHERE id=$1)', [idBranch]);
if (results.rowCount !== 1) {
throw new Error(`on a trouvé ${results.rowCount} crs pour le idBranch '${idBranch}'`);
}
return results.rows[0];
}

const sql = format('INSERT INTO patches (geom, id_branch, id_opi) values (ST_GeomFromGeoJSON(%L), %s, %s) RETURNING id as id_patch, num',
async function insertPatch(pgClient, idBranch, geometry, opiRefId, opiSecId, isAuto) {
debug(` ~~insertPatch (idBranch: ${idBranch})`);
const sql = format('INSERT INTO patches (geom, id_branch, id_opi, id_opisec, is_auto) VALUES (ST_GeomFromGeoJSON(%L), %L) RETURNING id as id_patch, num',
JSON.stringify(geometry),
idBranch,
opiId);
[idBranch,
opiRefId,
isAuto ? opiSecId : null,
isAuto]);
debug(sql);

const results = await pgClient.query(sql);
if (results.rowCount !== 1) {
throw new Error('failed to insert patch');
}

return results.rows[0];
}

Expand Down Expand Up @@ -554,6 +580,7 @@ module.exports = {
getUnactivePatches,
getOPIFromColor,
getOPIFromName,
getCrsFromIdBranch: getCacheCrsFromIdBranch,
insertPatch,
deactivatePatch,
reactivatePatch,
Expand Down
45 changes: 45 additions & 0 deletions db/geojson.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const debug = require('debug')('gjson');
const fs = require('fs');

async function writeGeojson(idBranch, idPatch, cachePath, geojson) {
debug(' ~~writeGeojson');
// create dir if it does not exist
const dir = `${cachePath}/tmp_test_js`;
try {
return fs.mkdirSync(dir);
} catch (error) {
if (error.code !== 'EEXIST') debug(error);
}

// write patch geojson
const filePath = `${dir}/patch_idBr${idBranch}_idP${idPatch}.geojson`;

const geojsonAna = JSON.parse(JSON.stringify(geojson));

geojsonAna.name = `${idBranch}_${idPatch}`;

const prop = geojson.features[0].properties;
if (prop.opiSec.name) {
geojsonAna.features[0].geometry.type = 'MultiLineString';
}
geojsonAna.features[0].geometry.coordinates = [geojsonAna.features[0].geometry.coordinates];

geojsonAna.features[0].properties = {
opiName: prop.opiRef.name,
color: prop.opiRef.color,
opiName2: prop.opiSec.name,
colorSec: prop.opiSec.color,
};

try {
fs.writeFileSync(filePath, JSON.stringify(geojsonAna, null, 2), 'utf8');
debug(` File '${filePath}' written`);
} catch (error) {
debug(error);
}
return filePath;
}

module.exports = {
writeGeojson,
};
Binary file modified doc/BD_packo.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 96 additions & 0 deletions doc/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ tags:
description: Récupération de fichiers
- name: process
description: Gestion des processus longs (donc asynchrones)
- name: ozcppexe
description: Lancement oz exe c++
paths:
# VERSION
'/version':
Expand Down Expand Up @@ -822,3 +824,97 @@ paths:
'200':
description: OK

# CPP EXE
'/ozCppExe':
get:
tags:
- ozcppexe
summary: "Lancement exe retouche semi-auto du graphe"
description: ""
parameters:
- in: query
name: fstOpi
description: first opi path
required: true
schema:
type: array
uniqueItems: true
items:
type: string
example: [opi1_0.tif]
- in: query
name: secOpi
description: second opi path
required: true
schema:
type: array
uniqueItems: true
items:
type: string
example: [opi2_0.tif]
- in: query
name: patch
description: geojson patch path
required: true
schema:
type: string
example: patch.geojson
- in: query
name: graph
description: geotiff_graph_path
required: true
schema:
type: array
uniqueItems: true
items:
type: string
example: [graph_0.tif]
- in: query
name: weightDiffCost
description: weight of difference cost, between 0 and 1
required: false
schema:
type: double
minimum: 0
maximum: 1
default: 0.95
- in: query
name: weightTransition
description: weight of transition cost
required: false
schema:
type: double
minimum: 0
default: 10.0
- in: query
name: minCost
description: minimum cost
required: false
schema:
type: double
default: 0.0001
- in: query
name: tension
description: tension
required: false
schema:
type: integer
default: 2
- in: query
name: border
description: border in meters
required: false
schema:
type: integer
default: 20
- in: query
name: outDir
description: output directory path
required: false
schema:
type: string
default: 'results'
responses:
'200':
description: OK

Loading
Loading