From 685be037b7114f1cdd2b317e36c0797aa23e86f6 Mon Sep 17 00:00:00 2001 From: p_monsalvete Date: Fri, 9 Jun 2023 11:38:46 -0400 Subject: [PATCH] redefined tutorial 1 --- support_material/tutorial_1/main_level_1.py | 49 ++++++++++++--------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/support_material/tutorial_1/main_level_1.py b/support_material/tutorial_1/main_level_1.py index 91c669c..05de731 100644 --- a/support_material/tutorial_1/main_level_1.py +++ b/support_material/tutorial_1/main_level_1.py @@ -1,33 +1,40 @@ from hub.imports.geometry_factory import GeometryFactory from hub.imports.construction_factory import ConstructionFactory from hub.helpers.dictionaries import Dictionaries -from hub.exports.exports_factory import ExportsFactory +import hub.helpers.constants as cte +MY_CUSTOM_DICTIONARY = { + '1000': cte.RESIDENTIAL +} -# tutorial_0: gml_file = 'FZK-Haus-LoD2-KIT-IAI-KHH-B36-V1.gml' +# case 3: Use a Hub dictionary when importing the geometry city = GeometryFactory('citygml', gml_file, function_to_hub=Dictionaries().montreal_function_to_hub_function).city for building in city.buildings: - print(building.name) - print(building.volume) - print(building.floor_area) + print(f"Year of construction of building {building.name} is: {building.year_of_construction}") + print(f"Function of building {building.name} is: {building.function}") + +# case 1: Use a Hub dictionary after importing the geometry +for building in city.buildings: + building.function = Dictionaries().montreal_function_to_hub_function[building.function] + +for building in city.buildings: + print(f"Hub-format function of building {building.name} is: {building.function}") + +# case 2: Create a new dictionary and use it after importing the geometry +for building in city.buildings: + building.function = MY_CUSTOM_DICTIONARY[building.function] + +for building in city.buildings: + print(f"Hub-format function of building {building.name} is: {building.function}") -# Level1: -city1 = city.copy - -for building in city1.buildings: - print ("Construction year of building in city1 is: ", building.year_of_construction) - print ("Building's function in city1 is: " , building.function) - -ConstructionFactory('nrcan',city1).enrich() - -for building in city1.buildings: - for internal_zone in building.internal_zones: - for thermal_zone in internal_zone.thermal_zones: - for thermal_boundary in thermal_zone.thermal_boundaries: - for layer in thermal_boundary.layers: - print(thermal_boundary.internal_surface.type) - print(layer.material.name) +ConstructionFactory('nrcan', city).enrich() +for building in city.buildings: + for thermal_zone in building.thermal_zones: + for thermal_boundary in thermal_zone.thermal_boundaries: + for layer in thermal_boundary.layers: + print(thermal_boundary.internal_surface.type) + print(layer.material.name)