added get_coordinates

This commit is contained in:
Khalim Conn-Kowlessar 2023-06-16 15:29:06 +01:00
parent 0398fb6eba
commit d1675e8478
2 changed files with 14 additions and 3 deletions

View file

@ -4,6 +4,7 @@ from model_data.OpenUprnClient import OpenUprnClient
class Property:
coordinates = None
def __init__(self, postcode, address1, epc_client=None, data=None):
self.postcode = postcode
@ -37,11 +38,18 @@ class Property:
self.data = response["rows"][0]
def get_coordinates(self, open_oprn_client: OpenUprnClient):
def get_coordinates(self, open_uprn_client: OpenUprnClient):
"""
This method utlises the OpenOprnClient to get the coordinates of the property
The OpenOprnClient interfactes with the Ordinance Survey Open UPRN database to extract
property coordinates. This database holds lookups between UPRN and coordinates.
:param open_oprn_client:
:return:
:param open_uprn_client: Instance of OpenOprnClient. This method expects the client to have already read
the data
"""
if not open_uprn_client.data:
raise ValueError("OpenUprnClient has not read data")
self.coordinates = open_uprn_client.data[
open_uprn_client.data["UPRN"] == self.data["uprn"]
].to_dict("records")[0]

View file

@ -34,6 +34,9 @@ def handler():
)
open_urpn_client.read()
for p in input_properties:
p.get_coordinates(open_urpn_client)
local_authorities = {p.data['local-authority'] for p in input_properties}
data = []