From 0b187a05a1c1f98dae7cc8e6a5855af7496a04ce Mon Sep 17 00:00:00 2001 From: Guille Date: Mon, 22 Jun 2020 14:35:40 -0400 Subject: [PATCH] Add max distance for adjacent buildings in the config file. If the distance is bigger than the given one it's not even checked for shared walls --- city_model_structure/city.py | 9 ++++++--- config/configuration.ini | 5 ++++- geometry/geometry_feeders/city_gml.py | 4 ++-- helpers/configuration_helper.py | 8 ++++++++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/city_model_structure/city.py b/city_model_structure/city.py index f12cc89f..a5270a6f 100644 --- a/city_model_structure/city.py +++ b/city_model_structure/city.py @@ -12,6 +12,7 @@ from pyproj import Transformer from city_model_structure.building import Building from city_model_structure.city_object import CityObject +from helpers.geometry_helper import GeometryHelper class City: @@ -26,6 +27,7 @@ class City: self._upper_corner = upper_corner self._buildings = buildings self._srs_name = srs_name + self._geometry = GeometryHelper() # todo: right now extracted at city level, in the future should be extracted also at building level if exist self._location = None @@ -138,9 +140,10 @@ class City: if self._buildings is None: self._buildings = [] for building in self.buildings: - for surface in building.surfaces: - for surface2 in new_city_object.surfaces: - surface.shared(surface2) + if self._geometry.adjacent_locations(building.location, new_city_object.location): + for surface in building.surfaces: + for surface2 in new_city_object.surfaces: + surface.shared(surface2) self._buildings.append(new_city_object) @property diff --git a/config/configuration.ini b/config/configuration.ini index 2f5f2e9b..54caaf41 100644 --- a/config/configuration.ini +++ b/config/configuration.ini @@ -16,4 +16,7 @@ indirectly_heated_area_ratio = 0 infiltration_rate_system_on = 0 outside_solar_absorptance = 0.2 shortwave_reflectance = 0.8 -min_air_change = 0.5 \ No newline at end of file +min_air_change = 0.5 + +[buildings] +max_location_distance_for_shared_walls = 200.0 \ No newline at end of file diff --git a/geometry/geometry_feeders/city_gml.py b/geometry/geometry_feeders/city_gml.py index e75777b6..fe573989 100644 --- a/geometry/geometry_feeders/city_gml.py +++ b/geometry/geometry_feeders/city_gml.py @@ -71,11 +71,11 @@ class CityGml: :return: City """ if self._city is None: + start = datetime.utcnow() self._city = City(self._lower_corner, self._upper_corner, self._srs_name) i = 0 for o in self._gml['CityModel']['cityObjectMember']: i += 1 - print('add city object', i) lod = 0 surfaces = [] if 'lod1Solid' in o['Building']: @@ -109,6 +109,7 @@ class CityGml: function = o['Building']['function'] self._city.add_city_object(Building(name, lod, surfaces, terrains, year_of_construction, function, self._lower_corner)) + print('city loaded in', datetime.utcnow()-start) return self._city def _terrains(self, city_object, lod_terrain_str): @@ -149,7 +150,6 @@ class CityGml: @staticmethod def _lod2(bound): - surfaces = [] for surface_type in iter(bound): for s in bound[surface_type]['lod2MultiSurface']['MultiSurface']['surfaceMember']: diff --git a/helpers/configuration_helper.py b/helpers/configuration_helper.py index 3b821ca2..7e545906 100644 --- a/helpers/configuration_helper.py +++ b/helpers/configuration_helper.py @@ -96,3 +96,11 @@ class ConfigurationHelper: :return: float """ return self._config.getfloat('thermal_zones', 'min_air_change') + + @property + def max_location_distance_for_shared_walls(self): + """ + Configured maximal distance between buildings to consider that they may share walls in meters + :return: float + """ + return self._config.getfloat('buildings', 'max_location_distance_for_shared_walls')