Skip to content

Commit

Permalink
add mapit call to get GSS codes by area type
Browse files Browse the repository at this point in the history
  • Loading branch information
struan committed Mar 21, 2024
1 parent c492c54 commit d3364b9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions utils/mapit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d3364b9

Please sign in to comment.