hub/imports/usage/hft_usage_parameters.py

43 lines
1.6 KiB
Python
Raw Normal View History

2021-01-06 16:42:38 -05:00
"""
HftUsageParameters model the usage properties
2021-01-06 16:42:38 -05:00
SPDX - License - Identifier: LGPL - 3.0 - or -later
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
from imports.geometry.helpers.geometry_helper import GeometryHelper
from imports.usage.hft_usage_interface import HftUsageInterface
from imports.usage.helpers.usage_helper import UsageHelper
2021-01-07 16:14:19 -05:00
class HftUsageParameters(HftUsageInterface):
2021-01-06 16:42:38 -05:00
"""
HftUsageParameters class
2021-01-06 16:42:38 -05:00
"""
def __init__(self, city, base_path):
super().__init__(base_path, 'de_library.xml')
2021-01-06 16:42:38 -05:00
self._city = city
def enrich_buildings(self):
2021-01-06 16:42:38 -05: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:
usage = GeometryHelper().libs_usage_from_libs_function(building.function)
try:
archetype = self._search_archetype(usage)
except KeyError:
sys.stderr.write(f'Building {building.name} has unknown archetype for building function:'
f' {building.function}, that assigns building usage as '
f'{GeometryHelper().libs_usage_from_libs_function(building.function)}\n')
return
2022-03-08 20:08:03 -05:00
for internal_zone in building.internal_zones:
libs_usage = GeometryHelper().libs_usage_from_libs_function(building.function)
usage_zone = self._assign_values(UsageHelper().hft_from_libs_usage(libs_usage), archetype)
usage_zone.percentage = 1
2022-12-06 15:28:59 -05:00
internal_zone.usages = [usage_zone]