Skip to content

Commit 79348a7

Browse files
fix: opti recupération geom RPG
1 parent 0478208 commit 79348a7

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

lib/providers/geometry.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,24 @@ async function verifyGeometry (inputGeomGeoJSON, recordId, id = '') {
7171
* Vérifie et corrige la géométrie entrée si besoin lors d'une création de parcelle
7272
* @param {number[]} extent - Extent du rpg dans la tuile cliquée
7373
*/
74-
async function getRpg (extent) {
74+
async function getRpg (extent, surface, codeCulture) {
7575
const { rows } = await pool.query(
7676
`
7777
SELECT rpg_bio.fid, ST_AsGeoJSON(ST_SetSRID(rpg_bio.geom, 3857))::json as geom
7878
FROM rpg_bio
7979
WHERE ST_Intersects(ST_MakeEnvelope($1, $2, $3, $4, 3857), ST_SetSRID(rpg_bio.geom, 3857))
80+
AND surf_adm = $5
81+
AND code_cultu = $6
8082
ORDER BY ST_Area(ST_Intersection(ST_MakeEnvelope($1, $2, $3, $4, 3857), ST_SetSRID(rpg_bio.geom, 3857))) DESC
8183
LIMIT 1
8284
`,
8385
[
8486
extent[0],
8587
extent[1],
8688
extent[2],
87-
extent[3]
89+
extent[3],
90+
surface,
91+
codeCulture
8892
]
8993
)
9094

0 commit comments

Comments
 (0)