From 79b90d9b5bb1ef16b8e2a8c6f3eea61640dad1ef Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Wed, 11 Dec 2024 12:27:33 +0100 Subject: [PATCH] fix: account for un-checked Article 4 values in GIS API (#4066) --- api.planx.uk/modules/gis/service/digitalLand.ts | 6 +++--- api.planx.uk/modules/gis/service/index.js | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/api.planx.uk/modules/gis/service/digitalLand.ts b/api.planx.uk/modules/gis/service/digitalLand.ts index f1a715d143..0f34267139 100644 --- a/api.planx.uk/modules/gis/service/digitalLand.ts +++ b/api.planx.uk/modules/gis/service/digitalLand.ts @@ -252,7 +252,7 @@ async function go( const a4s = planningConstraints["article4"]["records"] || undefined; // loop through any intersecting a4 data entities and set granular planx values based on this local authority's schema - if (a4s && formattedResult["article4"].value) { + if (a4s && formattedResult["article4"]?.value) { formattedResult["article4"]?.data?.forEach((entity: any) => { Object.keys(a4s)?.forEach((key) => { if ( @@ -280,8 +280,8 @@ async function go( // if caz is true, but parent a4 is false, sync a4 for accurate granularity if ( - formattedResult[localCaz].value && - !formattedResult["article4"].value + formattedResult[localCaz]?.value && + !formattedResult["article4"]?.value ) { formattedResult["article4"] = { fn: "article4", diff --git a/api.planx.uk/modules/gis/service/index.js b/api.planx.uk/modules/gis/service/index.js index 6332259c10..3908468810 100644 --- a/api.planx.uk/modules/gis/service/index.js +++ b/api.planx.uk/modules/gis/service/index.js @@ -18,6 +18,11 @@ const localAuthorities = { digitalLand }; * type: string * required: true * description: Well-Known Text (WKT) formatted polygon or point + * - in: query + * name: vals + * type: string + * required: false + * description: Comma-separated list of planning constraint values (formatted using `fn` property names) that should be returned */ export async function locationSearch(req, res, next) { // 'geom' param signals this localAuthority has data available via Planning Data