From c480a6c4cb54ddbbdba8607db904dd1f092a833e Mon Sep 17 00:00:00 2001 From: guille Date: Wed, 7 Apr 2021 12:06:21 -0400 Subject: [PATCH 1/3] Partial correction for unit tests --- tests/test_imports.py | 2 -- tests/test_physics_factory.py | 4 ++-- tests/test_weather_factory.py | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/test_imports.py b/tests/test_imports.py index 1c9c22e2..878ff405 100644 --- a/tests/test_imports.py +++ b/tests/test_imports.py @@ -10,8 +10,6 @@ from imports.geometry_factory import GeometryFactory class MyTestCase(TestCase): - def test_something(self): - self.assertEqual(True, False) """ TestImports """ diff --git a/tests/test_physics_factory.py b/tests/test_physics_factory.py index 5ea71ea6..4a4e94a1 100644 --- a/tests/test_physics_factory.py +++ b/tests/test_physics_factory.py @@ -33,7 +33,7 @@ class TestPhysicsFactory(TestCase): if self._nyc_with_physics is None: file_path = (self._example_path / '20buildings.gml').resolve() 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 def test_city_with_physics_extended_library(self): @@ -60,7 +60,7 @@ class TestPhysicsFactory(TestCase): def test_reduced_library(self): file_path = (self._example_path / 'lod2_buildings.gml').resolve() city = self._get_citygml(file_path) - PhysicsFactory('ca', city) + PhysicsFactory('ca', city).enrich() for building in city.buildings: self.assertIsNotNone(building.average_storey_height, 'average_storey_height is none') self.assertIsNotNone(building.storeys_above_ground, 'storeys_above_ground is none') diff --git a/tests/test_weather_factory.py b/tests/test_weather_factory.py index 8e313fa3..3e849d35 100644 --- a/tests/test_weather_factory.py +++ b/tests/test_weather_factory.py @@ -33,7 +33,7 @@ class TestWeatherFactory(TestCase): if self._city_with_weather is None: file_path = (Path(__file__).parent / 'tests_data' / '20buildings.gml').resolve() 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 def test_city_with_weather(self): @@ -55,7 +55,7 @@ class TestWeatherFactory(TestCase): def test_weather_xls(self): file_path = (Path(__file__).parent / 'tests_data' / 'iso_52016_1_2017_lod2.gml').resolve() 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: values = building.external_temperature['hour'][['iso52016']] self.assertFalse(values.empty, 'wrong value external_temperature') From 86fe064a25a312c8c959fb82eb9494d8ffbc4754 Mon Sep 17 00:00:00 2001 From: guille Date: Wed, 7 Apr 2021 12:57:56 -0400 Subject: [PATCH 2/3] Partial correction for unit tests --- city_model_structure/building.py | 17 ++++++++++------- imports/geometry_feeders/citygml.py | 9 ++++++--- tests/test_geometry_factory.py | 4 ++-- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/city_model_structure/building.py b/city_model_structure/building.py index 066f628c..f2dce1e6 100644 --- a/city_model_structure/building.py +++ b/city_model_structure/building.py @@ -25,7 +25,7 @@ class Building(CityObject): Building(CityObject) class """ def __init__(self, name, lod, surfaces, terrains, year_of_construction, function, - city_lower_corner, zones_surfaces_ids=[]): + city_lower_corner, zones_surfaces_ids=None): super().__init__(lod, surfaces, name, city_lower_corner) self._basement_heated = None self._attic_heated = None @@ -48,12 +48,15 @@ class Building(CityObject): self._internal_walls = [] self._thermal_zones = [] - for zone_surfaces_ids in zones_surfaces_ids: - zone_surfaces = [] - for surface_id in zone_surfaces_ids: - zone_surfaces.append(self.surface(surface_id)) - self._thermal_zones.append(ThermalZone(zone_surfaces)) - + zone_surfaces = None + if zones_surfaces_ids is not None: + for zone_surfaces_ids in zones_surfaces_ids: + 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: t_zones.bounded = [ThermalBoundary(s, [t_zones]) for s in t_zones.surfaces] for surface in self.surfaces: diff --git a/imports/geometry_feeders/citygml.py b/imports/geometry_feeders/citygml.py index d7b7f089..0c2f7c36 100644 --- a/imports/geometry_feeders/citygml.py +++ b/imports/geometry_feeders/citygml.py @@ -6,11 +6,13 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc import numpy as np import xmltodict + from city_model_structure.city import City from city_model_structure.building import Building from city_model_structure.attributes.surface import Surface from helpers.geometry_helper import GeometryHelper from city_model_structure.attributes.polygon import Polygon +from city_model_structure.attributes.thermal_zone import ThermalZone class CityGml: @@ -108,8 +110,9 @@ class CityGml: year_of_construction = o['Building']['yearOfConstruction'] if 'function' in o['Building']: function = o['Building']['function'] - self._city.add_city_object(Building(name, lod, surfaces, terrains, year_of_construction, function, - self._lower_corner)) + building = Building(name, lod, surfaces, terrains, year_of_construction, function, self._lower_corner) + self._city.add_city_object(building) + return self._city def _terrains(self, city_object, lod_terrain_str): @@ -174,7 +177,7 @@ class CityGml: if 'CompositeSurface' in s: surfaces = surfaces + CityGml._lod2_composite_surface(s) 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 @staticmethod diff --git a/tests/test_geometry_factory.py b/tests/test_geometry_factory.py index 40d53af9..2e3ce760 100644 --- a/tests/test_geometry_factory.py +++ b/tests/test_geometry_factory.py @@ -132,8 +132,8 @@ class TestGeometryFactory(TestCase): self.assertIsNotNone(thermal_zone.surfaces, 'thermal_zone surfaces 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.assertIsNone(thermal_zone.is_heated, 'thermal_zone heated is not none') - self.assertIsNone(thermal_zone.is_cooled, 'thermal_zone cooled is not none') + self.assertIsNotNone(thermal_zone.is_heated, 'thermal_zone heated is none') + self.assertIsNotNone(thermal_zone.is_cooled, 'thermal_zone cooled is none') self.assertIsNone(thermal_zone.additional_thermal_bridge_u_value, 'thermal_zone additional_thermal_bridge_u_value is not none') self.assertIsNone(thermal_zone.effective_thermal_capacity, From 1c444f3667b0bc0b3a3f421d7ca11fd4d1f2c679 Mon Sep 17 00:00:00 2001 From: guille Date: Wed, 7 Apr 2021 13:07:57 -0400 Subject: [PATCH 3/3] Correct energy ade export to work with new surfaces --- exports/formats/energy_ade.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/exports/formats/energy_ade.py b/exports/formats/energy_ade.py index 9a92b8d9..10ee8ba7 100644 --- a/exports/formats/energy_ade.py +++ b/exports/formats/energy_ade.py @@ -262,11 +262,9 @@ class EnergyAde: def _thermal_zones(self, building, city): thermal_zones = [] for index, thermal_zone in enumerate(building.thermal_zones): - print('debug me2') usage_zones = [] for usage_zone in thermal_zone.usage_zones: usage_zones.append({'@xlink:href': f'#GML_{usage_zone.id}'}) - thermal_zone_dic = { 'energy:ThermalZone': { '@gml:id': f'GML_{thermal_zone.id}', @@ -310,6 +308,7 @@ class EnergyAde: } thermal_zone_dic['energy:ThermalZone']['energy:contains'] = usage_zones thermal_zones.append(thermal_zone_dic) + print('debug me') return thermal_zones def _thermal_boundaries(self, city, thermal_zone): @@ -344,9 +343,9 @@ class EnergyAde: '@gml:id': f'GML_{uuid.uuid4()}', 'gml:posList': { '@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))} ' - f'{" ".join(map(str, thermal_boundary.surface.points[0]))}' + f'{" ".join(map(str, thermal_boundary.surface.solid_polygon.points[0]))}' } } }