2021-01-06 16:42:38 -05:00
|
|
|
"""
|
2021-06-03 15:56:59 -04:00
|
|
|
HftUsageParameters model the usage properties
|
2021-01-06 16:42:38 -05:00
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2022-04-08 09:35:33 -04:00
|
|
|
Copyright © 2022 Concordia CERC group
|
|
|
|
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
2021-01-06 16:42:38 -05:00
|
|
|
"""
|
2021-01-07 17:33:55 -05:00
|
|
|
import sys
|
|
|
|
|
2022-03-24 16:51:01 -04:00
|
|
|
from imports.geometry.helpers.geometry_helper import GeometryHelper
|
2021-06-03 15:56:59 -04:00
|
|
|
from imports.usage.hft_usage_interface import HftUsageInterface
|
2022-03-24 16:51:01 -04:00
|
|
|
from imports.usage.helpers.usage_helper import UsageHelper
|
2021-01-07 16:14:19 -05:00
|
|
|
|
2021-05-26 18:17:23 -04:00
|
|
|
|
2021-05-27 17:20:06 -04:00
|
|
|
class HftUsageParameters(HftUsageInterface):
|
2021-01-06 16:42:38 -05:00
|
|
|
"""
|
2021-05-27 17:20:06 -04:00
|
|
|
HftUsageParameters class
|
2021-01-06 16:42:38 -05:00
|
|
|
"""
|
|
|
|
def __init__(self, city, base_path):
|
2021-08-11 11:14:06 -04:00
|
|
|
super().__init__(base_path, 'de_library.xml')
|
2021-01-06 16:42:38 -05:00
|
|
|
self._city = city
|
|
|
|
|
2021-01-07 18:12:13 -05:00
|
|
|
def enrich_buildings(self):
|
2021-01-06 16:42:38 -05:00
|
|
|
"""
|
2021-06-03 15:56:59 -04:00
|
|
|
Returns the city with the usage parameters assigned to the buildings
|
2021-01-06 16:42:38 -05:00
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
city = self._city
|
|
|
|
for building in city.buildings:
|
2022-03-24 16:51:01 -04:00
|
|
|
usage = GeometryHelper().libs_usage_from_libs_function(building.function)
|
2022-03-17 18:49:44 -04:00
|
|
|
try:
|
|
|
|
archetype = self._search_archetype(usage)
|
|
|
|
except KeyError:
|
2021-05-27 17:20:06 -04:00
|
|
|
sys.stderr.write(f'Building {building.name} has unknown archetype for building function:'
|
2021-06-03 15:56:59 -04:00
|
|
|
f' {building.function}, that assigns building usage as '
|
2022-03-24 16:51:01 -04:00
|
|
|
f'{GeometryHelper().libs_usage_from_libs_function(building.function)}\n')
|
2022-03-17 18:49:44 -04:00
|
|
|
return
|
2022-03-08 20:08:03 -05:00
|
|
|
|
|
|
|
for internal_zone in building.internal_zones:
|
2022-03-24 16:51:01 -04:00
|
|
|
libs_usage = GeometryHelper().libs_usage_from_libs_function(building.function)
|
2022-05-16 10:19:03 -04:00
|
|
|
usage_zone = self._assign_values(UsageHelper().hft_from_libs_usage(libs_usage), archetype)
|
2022-03-17 18:49:44 -04:00
|
|
|
usage_zone.percentage = 1
|
|
|
|
internal_zone.usage_zones = [usage_zone]
|