""" CityGml module parses citygml_classes files and import the geometry into the city model structure SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Atiya """ import xmltodict from pathlib import Path from city_model_structure.building_demand.material import Material class LcaMaterial: def __init__(self, city, base_path): self._city = city self._base_path = base_path self._lca = None def enrich(self): self._city.materials = [] path = Path(self._base_path / 'lca_data.xml').resolve() with open(path) as xml: self._lca = xmltodict.parse(xml.read()) for material in self._lca["library"]["building_materials"]['material']: _material = Material() _material.type = material['@type'] _material.id = material['@id'] _material.name = material['@name'] _material.density=material['density']['#text'] _material.density_unit=material['density']['@unit'] _material.embodied_carbon=material['embodied_carbon']['#text'] _material.embodied_carbon_unit=material['embodied_carbon']['@unit'] _material.recycling_ratio=material['recycling_ratio'] _material.onsite_recycling_ratio=material['onsite_recycling_ratio'] _material.company_recycling_ratio=material['company_recycling_ratio'] _material.landfilling_ratio=material['landfilling_ratio'] _material.cost=material['cost']['#text'] _material._cost_unit=material['cost']['@unit'] self._city.materials.append(_material)