mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
class OrdnanceSuveyClient:
|
|
|
|
def __init__(self, address, postcode):
|
|
"""
|
|
This class is tasked with interaction with the ordnance survey API.
|
|
:param address:
|
|
:param postcode:
|
|
"""
|
|
|
|
self.address = address
|
|
self.postcode = postcode
|
|
|
|
def get_places_api(self):
|
|
"""
|
|
This method is tasked with getting the places api from the Ordnance Survey.
|
|
:return:
|
|
"""
|
|
pass
|
|
|
|
@staticmethod
|
|
def parse_classification_code(classification_code: str):
|
|
"""
|
|
This function will convert the classification code, returned by the OS places api, to a property type that is
|
|
compatible with the EPC database.
|
|
|
|
The various classifications cane be found here:
|
|
https://osdatahub.os.uk/docs/places/technicalSpecification
|
|
|
|
Under LPI Output, CLASSIFICATION_CODE is described, and a link is provided to the full table of classifications
|
|
For these purposes, we do not need the full classification as this includes non-residential properties. We only
|
|
parse the ones of interest to us
|
|
:return:
|
|
"""
|
|
|
|
value_map = {
|
|
# In the OS api, "RD" is a "Dwelling" however this is not valid property type in the EPC database
|
|
'RD': {},
|
|
'RD02': {'property_type': 'House', 'built_form': 'Detatched'},
|
|
'RD03': {'property_type': 'House', 'built_form': 'Semi-Detatched'},
|
|
'RD04': {'property_type': 'House', 'built_form': 'Mid-Terrace'},
|
|
'RD06': {'property_type': 'Flat'},
|
|
}
|
|
|
|
mapped = value_map.get(classification_code, {})
|
|
property_type = mapped.get("property_type", "")
|
|
built_form = mapped.get("built_form", "")
|
|
|
|
return property_type, built_form
|