From 552281907810447ffb2b1e678fa1e7c4b29f46c7 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Tue, 29 Oct 2024 14:54:28 -0300 Subject: [PATCH] fix(gadm): fix adm level validation --- services/geostore.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/geostore.js b/services/geostore.js index e8beaeb99e..f2ccd599da 100644 --- a/services/geostore.js +++ b/services/geostore.js @@ -60,7 +60,8 @@ const fetchGeostoreFromDataApi = ({ adm0, adm1, adm2, token }) => { const REGION = adm1 ? ` AND gid_1 LIKE '${adm0}.${adm1}__'` : ''; const SUBREGION = adm2 ? ` AND gid_2 LIKE '${adm0}.${adm1}.${adm2}__'` : ''; - const admLevel = (adm1 && adm2 ? 2 : 1) || 0; + const admLevel = adm2 || adm1 || 0; + const query = `SELECT gfw_bbox, gfw_geostore_id, ST_AsGeoJSON(ST_SimplifyPreserveTopology(ST_RemoveRepeatedPoints(geom, 0.001), 0.001)) AS gfw_geojson FROM gadm_administrative_boundaries WHERE adm_level='${admLevel}' AND ${COUNTRY}${REGION}${SUBREGION} limit 1`;