Skip to content

Commit

Permalink
fix(gadm): fix adm level validation
Browse files Browse the repository at this point in the history
  • Loading branch information
willian-viana committed Oct 29, 2024
1 parent 851de85 commit 402dd2b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion services/geostore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 && 2) || (adm1 && 1) || 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`;
Expand Down

0 comments on commit 402dd2b

Please sign in to comment.