diff --git a/exports/exports_factory.py b/exports/exports_factory.py index 06d90099..d2d214c3 100644 --- a/exports/exports_factory.py +++ b/exports/exports_factory.py @@ -16,10 +16,11 @@ class ExportsFactory: """ Exports factory class """ - def __init__(self, export_type, city, path): + def __init__(self, export_type, city, path, target_buildings=None): self._city = city self._export_type = '_' + export_type.lower() self._path = path + self._target_buildings = target_buildings @property def _citygml(self): @@ -65,7 +66,7 @@ class ExportsFactory: def _idf(self): """ Export the city to Energy+ idf format - :return: + :return: None """ idf_data_path = (Path(__file__).parent / './formats/idf_files/').resolve() # todo: create a get epw file function based on the city @@ -74,7 +75,12 @@ class ExportsFactory: @property def _sra(self): - return SimplifiedRadiosityAlgorithm(self._city, (self._path / f'{self._city.name}_sra.xml')) + """ + Export the city to Simplified Radiosity Algorithm xml format + :return: None + """ + return SimplifiedRadiosityAlgorithm(self._city, (self._path / f'{self._city.name}_sra.xml'), + target_buildings=self._target_buildings) def export(self): """ diff --git a/exports/formats/simplified_radiosity_algorithm.py b/exports/formats/simplified_radiosity_algorithm.py index 11205f41..9f5d6104 100644 --- a/exports/formats/simplified_radiosity_algorithm.py +++ b/exports/formats/simplified_radiosity_algorithm.py @@ -10,13 +10,14 @@ class SimplifiedRadiosityAlgorithm: """ Export to SRA format """ - def __init__(self, city, file_name, begin_month=1, begin_day=1, end_month=12, end_day=31): + def __init__(self, city, file_name, target_buildings=None, begin_month=1, begin_day=1, end_month=12, end_day=31): self._file_name = file_name self._begin_month = begin_month self._begin_day = begin_day self._end_month = end_month self._end_day = end_day self._city = city + self._target_buildings = target_buildings self._export() def _correct_point(self, point): @@ -26,15 +27,15 @@ class SimplifiedRadiosityAlgorithm: z = point[2] - self._city.lower_corner[2] return [x, y, z] - def _export(self, target_buildings_names=None): + def _export(self): buildings = [] for building_index, building in enumerate(self._city.buildings): - if target_buildings_names is None: + if self._target_buildings is None: simulate = 'true' else: simulate = 'false' - for name in target_buildings_names: - if building.name == name: + for target_building in self._target_buildings: + if building.name == target_building.name: simulate = 'true' building_dict = { '@Name': f'{building.name}',