""" Populate city SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es """ from imports.physics_factory import PhysicsFactory from imports.usage_factory import UsageFactory from city_model_structure.city import City class Populate: def __init__(self, city): self._city = city self._populated_city = None self._errors = [] @property def handler(self): if self._city.name == 'New York': handler = '{0}_{1}' return handler.format(self._city.country_code, self._city.name.lower().replace(' ', '_')) return self._city.country_code @property def errors(self): return self._errors @property def populated_city(self): if self._populated_city is None: self._errors = [] # Step 2.1: Thermal parameters tmp_city = City(self._city.lower_corner, self._city.upper_corner, self._city.srs_name) PhysicsFactory(self.handler, self._city) print('original:', len(self._city.buildings)) for building in self._city.buildings: # infiltration_rate_system_off is a mandatory parameter. # If it is not returned, extract the building from the calculation list if building.thermal_zones[0].infiltration_rate_system_off is not None: tmp_city.add_city_object(building) if tmp_city.buildings is None: self._populated_city = tmp_city return self._populated_city # Step 2.2: Usage parameters print('physics:', len(tmp_city.buildings)) UsageFactory(self.handler, tmp_city) self._populated_city = City(self._city.lower_corner, self._city.upper_corner, self._city.srs_name) for building in tmp_city.buildings: # heating_setpoint is a mandatory parameter. # If it is not returned, extract the building from the calculation list if len(building.usage_zones) > 0: self._populated_city.add_city_object(building) if self._populated_city.buildings is None: self._errors.append('no archetype found per usage') return self._populated_city