Repair energy ade export

This commit is contained in:
Guille Gutierrez 2023-02-07 06:16:08 -05:00
parent 19fc822147
commit b85a111a11
4 changed files with 66 additions and 55 deletions

View File

@ -417,3 +417,14 @@ class Building(CityObject):
Set the alias name for the building
"""
self._alias = value
@property
def usages_percentage(self):
"""
Get the usages and percentages for the building
"""
_usage = ''
for internal_zone in self.internal_zones:
for usage in internal_zone.usages:
_usage = f'{_usage}{usage.name}_{usage.percentage} '
return _usage.rstrip()

View File

@ -169,7 +169,7 @@ class EnergyAde:
def _building_geometry(self, building, building_dic, city):
building_dic['bldg:Building']['bldg:function'] = building.function
building_dic['bldg:Building']['bldg:usage'] = ', '.join([u.name for u in building.usages])
building_dic['bldg:Building']['bldg:usage'] = building.usages_percentage
building_dic['bldg:Building']['bldg:yearOfConstruction'] = building.year_of_construction
building_dic['bldg:Building']['bldg:roofType'] = building.roof_type
building_dic['bldg:Building']['bldg:measuredHeight'] = {
@ -178,9 +178,9 @@ class EnergyAde:
}
building_dic['bldg:Building']['bldg:storeysAboveGround'] = building.storeys_above_ground
if building.lod == 1:
if city.level_of_detail.geometry == 1:
building_dic = self._lod1(building, building_dic, city)
elif building.lod == 2:
elif city.level_of_detail.geometry == 2:
building_dic = self._lod2(building, building_dic, city)
else:
raise NotImplementedError('Only lod 1 and 2 can be exported')
@ -264,53 +264,53 @@ class EnergyAde:
def _thermal_zones(self, building, city):
thermal_zones = []
for index, thermal_zone in enumerate(building.thermal_zones):
usages = []
for usage in thermal_zone.usages:
usages.append({'@xlink:href': f'#GML_{usage.id}'})
thermal_zone_dic = {
'energy:ThermalZone': {
'@gml:id': f'GML_{thermal_zone.id}',
'gml:name': f'Thermal zone {index} in {building.name} building',
'energy:contains': [],
'energy:floorArea': {
'energy:FloorArea': {
'energy:type': 'grossFloorArea',
'energy:value': {
'@uom': 'm2',
'#text': f'{thermal_zone.footprint_area}'
}
}
},
'energy:volume': {
'energy:VolumeType': {
'energy:type': 'grossVolume',
'energy:value': {
'@uom': 'm3',
# todo: for now we have just one thermal zone, therefore is the building volume, this need to be changed
'#text': f'{building.volume}'
}
}
},
'energy:isCooled': f'{thermal_zone.is_cooled}',
'energy:isHeated': f'{thermal_zone.is_heated}',
'energy:volumeGeometry': {
'gml:Solid': {
'@gml:id': f'GML_{uuid.uuid4()}',
'gml:exterior': {
'gml:CompositeSurface': {
'@srsName': f'{city.srs_name}',
'@gml:id': f'GML_{uuid.uuid4()}',
'gml:surfaceMember': self._surface_members
for internal_zone in building.internal_zones:
for index, thermal_zone in enumerate(internal_zone.thermal_zones):
usages = []
for usage in internal_zone.usages:
usages.append({'@xlink:href': f'#GML_{usage.id}'})
thermal_zone_dic = {
'energy:ThermalZone': {
'@gml:id': f'GML_{thermal_zone.id}',
'gml:name': f'Thermal zone {index} in {building.name} building',
'energy:contains': [],
'energy:floorArea': {
'energy:FloorArea': {
'energy:type': 'grossFloorArea',
'energy:value': {
'@uom': 'm2',
'#text': f'{thermal_zone.footprint_area}'
}
}
}
},
'energy:boundedBy': self._thermal_boundaries(city, thermal_zone)
},
'energy:volume': {
'energy:VolumeType': {
'energy:type': 'grossVolume',
'energy:value': {
'@uom': 'm3',
'#text': f'{thermal_zone.volume}'
}
}
},
'energy:isCooled': f'{building.is_conditioned}',
'energy:isHeated': f'{building.is_conditioned}',
'energy:volumeGeometry': {
'gml:Solid': {
'@gml:id': f'GML_{uuid.uuid4()}',
'gml:exterior': {
'gml:CompositeSurface': {
'@srsName': f'{city.srs_name}',
'@gml:id': f'GML_{uuid.uuid4()}',
'gml:surfaceMember': self._surface_members
}
}
}
},
'energy:boundedBy': self._thermal_boundaries(city, thermal_zone)
}
}
}
thermal_zone_dic['energy:ThermalZone']['energy:contains'] = usages
thermal_zones.append(thermal_zone_dic)
thermal_zone_dic['energy:ThermalZone']['energy:contains'] = usages
thermal_zones.append(thermal_zone_dic)
return thermal_zones
@staticmethod
@ -323,11 +323,11 @@ class EnergyAde:
'energy:thermalBoundaryType': thermal_boundary.type,
'energy:azumuth': {
'@uom': 'rad',
'#text': f'{thermal_boundary.azimuth}'
'#text': f'{thermal_boundary.parent_surface.azimuth}'
},
'energy:inclination': {
'@uom': 'rad',
'#text': f'{thermal_boundary.inclination}'
'#text': f'{thermal_boundary.parent_surface.inclination}'
},
'energy:area': {
'@uom': 'm2',
@ -346,9 +346,9 @@ class EnergyAde:
'@gml:id': f'GML_{uuid.uuid4()}',
'gml:posList': {
'@srsDimension': '3',
'@count': len(thermal_boundary.surface.solid_polygon.coordinates) + 1,
'#text': f'{" ".join(map(str, thermal_boundary.surface.solid_polygon.points_list))} '
f'{" ".join(map(str, thermal_boundary.surface.solid_polygon.coordinates[0]))}'
'@count': len(thermal_boundary.parent_surface.solid_polygon.coordinates) + 1,
'#text': f'{" ".join(map(str, thermal_boundary.parent_surface.solid_polygon.points_list))} '
f'{" ".join(map(str, thermal_boundary.parent_surface.solid_polygon.coordinates[0]))}'
}
}
}

View File

@ -104,7 +104,7 @@ class TestConstructionFactory(TestCase):
self.assertIsNone(building.households, 'building households is not none')
self.assertFalse(building.is_conditioned, 'building is conditioned')
self.assertIsNotNone(building.shell, 'building shell is none')
self.assertIsNone(building.human_readable_name, 'building human_readable_name is not none')
self.assertIsNone(building.alias, 'building alias is not none')
def _check_thermal_zones(self, internal_zone):
for thermal_zone in internal_zone.thermal_zones:

View File

@ -84,8 +84,7 @@ setup(
data_files=[
('hub', glob.glob('hub/requirements.txt')),
('hub/config', glob.glob('hub/config/*.ini')),
('hub/catalog_factories/greenery/ecore_greenery',
glob.glob('hub/catalog_factories/greenery/ecore_greenery/*.ecore')),
('hub/catalog_factories/greenery/ecore_greenery', glob.glob('hub/catalog_factories/greenery/ecore_greenery/*.ecore')),
('hub/data/construction.', glob.glob('hub/data/construction/*.xml')),
('hub/data/customized_imports/', glob.glob('hub/data/customized_imports/*.xml')),
('hub/data/energy_systems/', glob.glob('hub/data/energy_systems/*.xml')),
@ -105,6 +104,7 @@ setup(
('hub/data/weather/epw/', glob.glob('hub/data/weather/epw/*.epw')),
('hub/data/weather/', glob.glob('hub/data/weather/*.dat')),
('hub/exports/building_energy/idf_files', glob.glob('hub/exports/building_energy/idf_files/*.idf')),
('hub/exports/building_energy/idf_files', glob.glob('hub/exports/building_energy/idf_files/*.idd')),
('hub/helpers/data', glob.glob('hub/helpers/data/quebec_to_hub.json'))
],