Merge remote-tracking branch 'origin/master'

# Conflicts:
#	city_model_structure/building.py
#	imports/geometry_feeders/citygml.py
This commit is contained in:
Pilar 2021-04-07 14:23:41 -04:00
commit ff701e7f77
6 changed files with 25 additions and 21 deletions

View File

@ -24,8 +24,8 @@ class Building(CityObject):
""" """
Building(CityObject) class Building(CityObject) class
""" """
def __init__(self, name, lod, surfaces, year_of_construction, function, def __init__(self, name, lod, surfaces, terrains, year_of_construction, function,
city_lower_corner, terrains=None, zones_surfaces_ids=[]): city_lower_corner, zones_surfaces_ids=[]):
super().__init__(lod, surfaces, name, city_lower_corner) super().__init__(lod, surfaces, name, city_lower_corner)
self._basement_heated = None self._basement_heated = None
self._attic_heated = None self._attic_heated = None
@ -48,12 +48,15 @@ class Building(CityObject):
self._internal_walls = [] self._internal_walls = []
self._thermal_zones = [] self._thermal_zones = []
for zone_surfaces_ids in zones_surfaces_ids: zone_surfaces = None
zone_surfaces = [] if zones_surfaces_ids is not None:
for surface_id in zone_surfaces_ids: for zone_surfaces_ids in zones_surfaces_ids:
zone_surfaces.append(self.surface(surface_id)) zone_surfaces = []
self._thermal_zones.append(ThermalZone(zone_surfaces)) for surface_id in zone_surfaces_ids:
zone_surfaces.append(self.surface(surface_id))
else:
zone_surfaces = surfaces
self._thermal_zones.append(ThermalZone(zone_surfaces))
for t_zones in self._thermal_zones: for t_zones in self._thermal_zones:
t_zones.bounded = [ThermalBoundary(s, [t_zones]) for s in t_zones.surfaces] t_zones.bounded = [ThermalBoundary(s, [t_zones]) for s in t_zones.surfaces]
for surface in self.surfaces: for surface in self.surfaces:

View File

@ -262,11 +262,9 @@ 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 index, thermal_zone in enumerate(building.thermal_zones):
print('debug me2')
usage_zones = [] usage_zones = []
for usage_zone in thermal_zone.usage_zones: for usage_zone in thermal_zone.usage_zones:
usage_zones.append({'@xlink:href': f'#GML_{usage_zone.id}'}) usage_zones.append({'@xlink:href': f'#GML_{usage_zone.id}'})
thermal_zone_dic = { thermal_zone_dic = {
'energy:ThermalZone': { 'energy:ThermalZone': {
'@gml:id': f'GML_{thermal_zone.id}', '@gml:id': f'GML_{thermal_zone.id}',
@ -310,6 +308,7 @@ class EnergyAde:
} }
thermal_zone_dic['energy:ThermalZone']['energy:contains'] = usage_zones thermal_zone_dic['energy:ThermalZone']['energy:contains'] = usage_zones
thermal_zones.append(thermal_zone_dic) thermal_zones.append(thermal_zone_dic)
print('debug me')
return thermal_zones return thermal_zones
def _thermal_boundaries(self, city, thermal_zone): def _thermal_boundaries(self, city, thermal_zone):
@ -344,9 +343,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.points) + 1, '@count': len(thermal_boundary.surface.solid_polygon.points) + 1,
'#text': f'{" ".join(map(str, thermal_boundary.surface.solid_polygon.points_list))} ' '#text': f'{" ".join(map(str, thermal_boundary.surface.solid_polygon.points_list))} '
f'{" ".join(map(str, thermal_boundary.surface.points[0]))}' f'{" ".join(map(str, thermal_boundary.surface.solid_polygon.points[0]))}'
} }
} }
} }

View File

@ -11,6 +11,7 @@ from city_model_structure.building import Building
from city_model_structure.attributes.surface import Surface from city_model_structure.attributes.surface import Surface
from helpers.geometry_helper import GeometryHelper from helpers.geometry_helper import GeometryHelper
from city_model_structure.attributes.polygon import Polygon from city_model_structure.attributes.polygon import Polygon
from city_model_structure.attributes.thermal_zone import ThermalZone
class CityGml: class CityGml:
@ -108,8 +109,9 @@ class CityGml:
year_of_construction = o['Building']['yearOfConstruction'] year_of_construction = o['Building']['yearOfConstruction']
if 'function' in o['Building']: if 'function' in o['Building']:
function = o['Building']['function'] function = o['Building']['function']
self._city.add_city_object(Building(name, lod, surfaces, year_of_construction, function, building = Building(name, lod, surfaces, year_of_construction, function, self._lower_corner, terrains)
self._lower_corner, terrains)) self._city.add_city_object(building)
return self._city return self._city
def _terrains(self, city_object, lod_terrain_str): def _terrains(self, city_object, lod_terrain_str):
@ -174,7 +176,7 @@ class CityGml:
if 'CompositeSurface' in s: if 'CompositeSurface' in s:
surfaces = surfaces + CityGml._lod2_composite_surface(s) surfaces = surfaces + CityGml._lod2_composite_surface(s)
else: else:
surfaces = surfaces + CityGml._lod2_multi_surface(s, surface_type) surfaces = surfaces + CityGml._lod2_multi_surface(s, GeometryHelper.gml_surface_to_libs(surface_type))
return surfaces return surfaces
@staticmethod @staticmethod

View File

@ -132,8 +132,8 @@ class TestGeometryFactory(TestCase):
self.assertIsNotNone(thermal_zone.surfaces, 'thermal_zone surfaces is none') self.assertIsNotNone(thermal_zone.surfaces, 'thermal_zone surfaces is none')
self.assertIsNotNone(thermal_zone.bounded, 'thermal_zone bounded is none') self.assertIsNotNone(thermal_zone.bounded, 'thermal_zone bounded is none')
self.assertIsNotNone(thermal_zone.floor_area, 'thermal_zone floor_area is none') self.assertIsNotNone(thermal_zone.floor_area, 'thermal_zone floor_area is none')
self.assertIsNone(thermal_zone.is_heated, 'thermal_zone heated is not none') self.assertIsNotNone(thermal_zone.is_heated, 'thermal_zone heated is none')
self.assertIsNone(thermal_zone.is_cooled, 'thermal_zone cooled is not none') self.assertIsNotNone(thermal_zone.is_cooled, 'thermal_zone cooled is none')
self.assertIsNone(thermal_zone.additional_thermal_bridge_u_value, self.assertIsNone(thermal_zone.additional_thermal_bridge_u_value,
'thermal_zone additional_thermal_bridge_u_value is not none') 'thermal_zone additional_thermal_bridge_u_value is not none')
self.assertIsNone(thermal_zone.effective_thermal_capacity, self.assertIsNone(thermal_zone.effective_thermal_capacity,

View File

@ -33,7 +33,7 @@ class TestPhysicsFactory(TestCase):
if self._nyc_with_physics is None: if self._nyc_with_physics is None:
file_path = (self._example_path / '20buildings.gml').resolve() file_path = (self._example_path / '20buildings.gml').resolve()
self._nyc_with_physics = self._get_citygml(file_path) self._nyc_with_physics = self._get_citygml(file_path)
PhysicsFactory('us_new_york', self._nyc_with_physics) PhysicsFactory('us_new_york', self._nyc_with_physics).enrich()
return self._nyc_with_physics return self._nyc_with_physics
def test_city_with_physics_extended_library(self): def test_city_with_physics_extended_library(self):
@ -60,7 +60,7 @@ class TestPhysicsFactory(TestCase):
def test_reduced_library(self): def test_reduced_library(self):
file_path = (self._example_path / 'lod2_buildings.gml').resolve() file_path = (self._example_path / 'lod2_buildings.gml').resolve()
city = self._get_citygml(file_path) city = self._get_citygml(file_path)
PhysicsFactory('ca', city) PhysicsFactory('ca', city).enrich()
for building in city.buildings: for building in city.buildings:
self.assertIsNotNone(building.average_storey_height, 'average_storey_height is none') self.assertIsNotNone(building.average_storey_height, 'average_storey_height is none')
self.assertIsNotNone(building.storeys_above_ground, 'storeys_above_ground is none') self.assertIsNotNone(building.storeys_above_ground, 'storeys_above_ground is none')

View File

@ -33,7 +33,7 @@ class TestWeatherFactory(TestCase):
if self._city_with_weather is None: if self._city_with_weather is None:
file_path = (Path(__file__).parent / 'tests_data' / '20buildings.gml').resolve() file_path = (Path(__file__).parent / 'tests_data' / '20buildings.gml').resolve()
self._city_with_weather = self._get_citygml(file_path) self._city_with_weather = self._get_citygml(file_path)
WeatherFactory('dat', self._city_with_weather, city_name=self._city_name, base_path=self._example_path) WeatherFactory('dat', self._city_with_weather, city_name=self._city_name, base_path=self._example_path).enrich()
return self._city_with_weather return self._city_with_weather
def test_city_with_weather(self): def test_city_with_weather(self):
@ -55,7 +55,7 @@ class TestWeatherFactory(TestCase):
def test_weather_xls(self): def test_weather_xls(self):
file_path = (Path(__file__).parent / 'tests_data' / 'iso_52016_1_2017_lod2.gml').resolve() file_path = (Path(__file__).parent / 'tests_data' / 'iso_52016_1_2017_lod2.gml').resolve()
city_with_weather = self._get_citygml(file_path) city_with_weather = self._get_citygml(file_path)
WeatherFactory('xls', city_with_weather, city_name=self._city_name, base_path=self._example_path) WeatherFactory('xls', city_with_weather, city_name=self._city_name, base_path=self._example_path).enrich()
for building in city_with_weather.buildings: for building in city_with_weather.buildings:
values = building.external_temperature['hour'][['iso52016']] values = building.external_temperature['hour'][['iso52016']]
self.assertFalse(values.empty, 'wrong value external_temperature') self.assertFalse(values.empty, 'wrong value external_temperature')