Skip to content

Commit a2e3533

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

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
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

server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,8 +733,8 @@ app.register(async (app) => {
733733
app.post('/api/v2/geometry/rpg', mergeSchemas(
734734
protectedWithToken()
735735
), (request, reply) => {
736-
const { payload: extent } = request.body
737-
return getRpg(extent)
736+
const { extent, surface, codeCulture } = request.body
737+
return getRpg(extent, surface, codeCulture)
738738
.then(data => {
739739
if (data) {
740740
return reply.code(200).send((data))

0 commit comments

Comments
 (0)