forked from s_ranjbar/city_retrofit
Repair energy ade export
This commit is contained in:
parent
19fc822147
commit
b85a111a11
@ -417,3 +417,14 @@ class Building(CityObject):
|
|||||||
Set the alias name for the building
|
Set the alias name for the building
|
||||||
"""
|
"""
|
||||||
self._alias = value
|
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()
|
||||||
|
@ -169,7 +169,7 @@ class EnergyAde:
|
|||||||
def _building_geometry(self, building, building_dic, city):
|
def _building_geometry(self, building, building_dic, city):
|
||||||
|
|
||||||
building_dic['bldg:Building']['bldg:function'] = building.function
|
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:yearOfConstruction'] = building.year_of_construction
|
||||||
building_dic['bldg:Building']['bldg:roofType'] = building.roof_type
|
building_dic['bldg:Building']['bldg:roofType'] = building.roof_type
|
||||||
building_dic['bldg:Building']['bldg:measuredHeight'] = {
|
building_dic['bldg:Building']['bldg:measuredHeight'] = {
|
||||||
@ -178,9 +178,9 @@ class EnergyAde:
|
|||||||
}
|
}
|
||||||
building_dic['bldg:Building']['bldg:storeysAboveGround'] = building.storeys_above_ground
|
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)
|
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)
|
building_dic = self._lod2(building, building_dic, city)
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError('Only lod 1 and 2 can be exported')
|
raise NotImplementedError('Only lod 1 and 2 can be exported')
|
||||||
@ -264,53 +264,53 @@ class EnergyAde:
|
|||||||
|
|
||||||
def _thermal_zones(self, building, city):
|
def _thermal_zones(self, building, city):
|
||||||
thermal_zones = []
|
thermal_zones = []
|
||||||
for index, thermal_zone in enumerate(building.thermal_zones):
|
for internal_zone in building.internal_zones:
|
||||||
usages = []
|
for index, thermal_zone in enumerate(internal_zone.thermal_zones):
|
||||||
for usage in thermal_zone.usages:
|
usages = []
|
||||||
usages.append({'@xlink:href': f'#GML_{usage.id}'})
|
for usage in internal_zone.usages:
|
||||||
thermal_zone_dic = {
|
usages.append({'@xlink:href': f'#GML_{usage.id}'})
|
||||||
'energy:ThermalZone': {
|
thermal_zone_dic = {
|
||||||
'@gml:id': f'GML_{thermal_zone.id}',
|
'energy:ThermalZone': {
|
||||||
'gml:name': f'Thermal zone {index} in {building.name} building',
|
'@gml:id': f'GML_{thermal_zone.id}',
|
||||||
'energy:contains': [],
|
'gml:name': f'Thermal zone {index} in {building.name} building',
|
||||||
'energy:floorArea': {
|
'energy:contains': [],
|
||||||
'energy:FloorArea': {
|
'energy:floorArea': {
|
||||||
'energy:type': 'grossFloorArea',
|
'energy:FloorArea': {
|
||||||
'energy:value': {
|
'energy:type': 'grossFloorArea',
|
||||||
'@uom': 'm2',
|
'energy:value': {
|
||||||
'#text': f'{thermal_zone.footprint_area}'
|
'@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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
'energy:volume': {
|
||||||
'energy:boundedBy': self._thermal_boundaries(city, thermal_zone)
|
'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_zone_dic['energy:ThermalZone']['energy:contains'] = usages
|
thermal_zones.append(thermal_zone_dic)
|
||||||
thermal_zones.append(thermal_zone_dic)
|
|
||||||
return thermal_zones
|
return thermal_zones
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -323,11 +323,11 @@ class EnergyAde:
|
|||||||
'energy:thermalBoundaryType': thermal_boundary.type,
|
'energy:thermalBoundaryType': thermal_boundary.type,
|
||||||
'energy:azumuth': {
|
'energy:azumuth': {
|
||||||
'@uom': 'rad',
|
'@uom': 'rad',
|
||||||
'#text': f'{thermal_boundary.azimuth}'
|
'#text': f'{thermal_boundary.parent_surface.azimuth}'
|
||||||
},
|
},
|
||||||
'energy:inclination': {
|
'energy:inclination': {
|
||||||
'@uom': 'rad',
|
'@uom': 'rad',
|
||||||
'#text': f'{thermal_boundary.inclination}'
|
'#text': f'{thermal_boundary.parent_surface.inclination}'
|
||||||
},
|
},
|
||||||
'energy:area': {
|
'energy:area': {
|
||||||
'@uom': 'm2',
|
'@uom': 'm2',
|
||||||
@ -346,9 +346,9 @@ class EnergyAde:
|
|||||||
'@gml:id': f'GML_{uuid.uuid4()}',
|
'@gml:id': f'GML_{uuid.uuid4()}',
|
||||||
'gml:posList': {
|
'gml:posList': {
|
||||||
'@srsDimension': '3',
|
'@srsDimension': '3',
|
||||||
'@count': len(thermal_boundary.surface.solid_polygon.coordinates) + 1,
|
'@count': len(thermal_boundary.parent_surface.solid_polygon.coordinates) + 1,
|
||||||
'#text': f'{" ".join(map(str, thermal_boundary.surface.solid_polygon.points_list))} '
|
'#text': f'{" ".join(map(str, thermal_boundary.parent_surface.solid_polygon.points_list))} '
|
||||||
f'{" ".join(map(str, thermal_boundary.surface.solid_polygon.coordinates[0]))}'
|
f'{" ".join(map(str, thermal_boundary.parent_surface.solid_polygon.coordinates[0]))}'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ class TestConstructionFactory(TestCase):
|
|||||||
self.assertIsNone(building.households, 'building households is not none')
|
self.assertIsNone(building.households, 'building households is not none')
|
||||||
self.assertFalse(building.is_conditioned, 'building is conditioned')
|
self.assertFalse(building.is_conditioned, 'building is conditioned')
|
||||||
self.assertIsNotNone(building.shell, 'building shell is none')
|
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):
|
def _check_thermal_zones(self, internal_zone):
|
||||||
for thermal_zone in internal_zone.thermal_zones:
|
for thermal_zone in internal_zone.thermal_zones:
|
||||||
|
4
setup.py
4
setup.py
@ -84,8 +84,7 @@ setup(
|
|||||||
data_files=[
|
data_files=[
|
||||||
('hub', glob.glob('hub/requirements.txt')),
|
('hub', glob.glob('hub/requirements.txt')),
|
||||||
('hub/config', glob.glob('hub/config/*.ini')),
|
('hub/config', glob.glob('hub/config/*.ini')),
|
||||||
('hub/catalog_factories/greenery/ecore_greenery',
|
('hub/catalog_factories/greenery/ecore_greenery', glob.glob('hub/catalog_factories/greenery/ecore_greenery/*.ecore')),
|
||||||
glob.glob('hub/catalog_factories/greenery/ecore_greenery/*.ecore')),
|
|
||||||
('hub/data/construction.', glob.glob('hub/data/construction/*.xml')),
|
('hub/data/construction.', glob.glob('hub/data/construction/*.xml')),
|
||||||
('hub/data/customized_imports/', glob.glob('hub/data/customized_imports/*.xml')),
|
('hub/data/customized_imports/', glob.glob('hub/data/customized_imports/*.xml')),
|
||||||
('hub/data/energy_systems/', glob.glob('hub/data/energy_systems/*.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/epw/', glob.glob('hub/data/weather/epw/*.epw')),
|
||||||
('hub/data/weather/', glob.glob('hub/data/weather/*.dat')),
|
('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/*.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'))
|
('hub/helpers/data', glob.glob('hub/helpers/data/quebec_to_hub.json'))
|
||||||
],
|
],
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user