mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
added get_coordinates
This commit is contained in:
parent
0398fb6eba
commit
d1675e8478
2 changed files with 14 additions and 3 deletions
|
|
@ -4,6 +4,7 @@ from model_data.OpenUprnClient import OpenUprnClient
|
||||||
|
|
||||||
|
|
||||||
class Property:
|
class Property:
|
||||||
|
coordinates = None
|
||||||
|
|
||||||
def __init__(self, postcode, address1, epc_client=None, data=None):
|
def __init__(self, postcode, address1, epc_client=None, data=None):
|
||||||
self.postcode = postcode
|
self.postcode = postcode
|
||||||
|
|
@ -37,11 +38,18 @@ class Property:
|
||||||
|
|
||||||
self.data = response["rows"][0]
|
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
|
This method utlises the OpenOprnClient to get the coordinates of the property
|
||||||
The OpenOprnClient interfactes with the Ordinance Survey Open UPRN database to extract
|
The OpenOprnClient interfactes with the Ordinance Survey Open UPRN database to extract
|
||||||
property coordinates. This database holds lookups between UPRN and coordinates.
|
property coordinates. This database holds lookups between UPRN and coordinates.
|
||||||
:param open_oprn_client:
|
:param open_uprn_client: Instance of OpenOprnClient. This method expects the client to have already read
|
||||||
:return:
|
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]
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,9 @@ def handler():
|
||||||
)
|
)
|
||||||
open_urpn_client.read()
|
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}
|
local_authorities = {p.data['local-authority'] for p in input_properties}
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue