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
This commit is contained in:
Guille Gutierrez 2020-06-22 14:35:40 -04:00
parent 9d921da698
commit 0b187a05a1
4 changed files with 20 additions and 6 deletions

View File

@ -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

View File

@ -17,3 +17,6 @@ infiltration_rate_system_on = 0
outside_solar_absorptance = 0.2
shortwave_reflectance = 0.8
min_air_change = 0.5
[buildings]
max_location_distance_for_shared_walls = 200.0

View File

@ -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']:

View File

@ -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')