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,