From 3ad5d20d1c21acb25395865501ea386bbdfad82e Mon Sep 17 00:00:00 2001 From: majidrezaei93 Date: Thu, 3 Oct 2024 09:25:39 -0400 Subject: [PATCH] feat: add simplified building and city to city model structure --- .../simplified_building.py | 42 +++++++++++++++++++ hub/city_model_structure/simplified_city.py | 31 ++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 hub/city_model_structure/simplified_building.py create mode 100644 hub/city_model_structure/simplified_city.py diff --git a/hub/city_model_structure/simplified_building.py b/hub/city_model_structure/simplified_building.py new file mode 100644 index 00000000..4d49f232 --- /dev/null +++ b/hub/city_model_structure/simplified_building.py @@ -0,0 +1,42 @@ +from typing import Union + + +class SimplifiedBuilding: + """ + SimplifiedBuilding class + """ + def __init__(self, name, total_floor_area=None, year_of_construction=None, function=None, city=None): + self._name = name + self._total_floor_area = total_floor_area + self._year_of_construction = year_of_construction + self._function = function + self._city = city + self._type = 'building' + + @property + def name(self): + return self._name + + @property + def total_floor_area(self): + return self._total_floor_area + + @property + def year_of_construction(self): + return self._year_of_construction + + @property + def function(self) -> Union[None, str]: + return self._function + + @property + def type(self): + return self._type + + @property + def city(self): + return self._city + + @city.setter + def city(self, value): + self._city = value diff --git a/hub/city_model_structure/simplified_city.py b/hub/city_model_structure/simplified_city.py new file mode 100644 index 00000000..2967c40b --- /dev/null +++ b/hub/city_model_structure/simplified_city.py @@ -0,0 +1,31 @@ +from typing import List +from hub.city_model_structure.simplified_building import SimplifiedBuilding + +class SimplifiedCity: + """ + SimplifiedCity class + """ + + def __init__(self): + self._name = "Montreal Metropolitan Area" + self._buildings = [] + + @property + def name(self): + return self._name + + @name.setter + def name(self, value): + if value is not None: + self._name = str(value) + + @property + def buildings(self) -> List[SimplifiedBuilding]: + return self._buildings + + def add_city_object(self, new_city_object): + if new_city_object.type == 'building': + self._buildings.append(new_city_object) + new_city_object.city = self + else: + raise NotImplementedError(f"Type {new_city_object.type} is not supported")