From d3364b94b33ca3204f5e17f8db044eb5d036e81d Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Thu, 21 Mar 2024 14:53:43 +0000 Subject: [PATCH] add mapit call to get GSS codes by area type --- utils/mapit.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/utils/mapit.py b/utils/mapit.py index bc55753e3..82e51acb3 100644 --- a/utils/mapit.py +++ b/utils/mapit.py @@ -84,6 +84,15 @@ def wgs84_point_to_gss_codes(self, lon, lat): gss_codes.append(area["codes"]["gss"]) return gss_codes + def wgs84_point_to_gss_codes_with_type(self, lon, lat): + url = self.wgs84_url % (self.base, lon, lat, settings.MAPIT_API_KEY) + data = self.get(url) + gss_codes = {} + for area in data.values(): + if "gss" in area["codes"]: + gss_codes[area["type"]] = area["codes"]["gss"] + return gss_codes + def areas_of_type(self, types): url = self.areas_url % (self.base, ",".join(types), settings.MAPIT_API_KEY) data = self.get(url)