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`;