feat: add simplified building and city to city model structure
This commit is contained in:
parent
5e01f4eb7f
commit
a477a2b893
42
hub/city_model_structure/simplified_building.py
Normal file
42
hub/city_model_structure/simplified_building.py
Normal file
|
@ -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
|
31
hub/city_model_structure/simplified_city.py
Normal file
31
hub/city_model_structure/simplified_city.py
Normal file
|
@ -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")
|
Loading…
Reference in New Issue
Block a user