partially implemented shared walls

This commit is contained in:
Pilar 2023-02-23 07:25:04 -05:00
parent e04b713416
commit 7092f43f32
4 changed files with 35 additions and 16 deletions

View File

@ -447,9 +447,20 @@ class Building(CityObject):
Identifies which building' walls adjoin the neighbouring building and saves that information in the
corresponding surfaces
"""
for wall in self.walls:
percentage = 0
for building in self._neighbours:
for neighbour_wall in building.walls:
percentage += wall.shared_percentage(neighbour_wall)
wall.set_shared_percentage(percentage)
x = int((self.upper_corner[0] - self.lower_corner[0]) / 2)
y = int((self.upper_corner[1] - self.lower_corner[1]) / 2)
city_map = [['' for _ in range(y+1)] for _ in range(x+1)]
city_image = [[0 for _ in range(y+1)] for _ in range(x+1)]
for building_name in building_names:
building = city.city_object(building_name)
for ground in building.grounds:
length = len(ground.perimeter_polygon.coordinates) - 1
for i, coordinate in enumerate(ground.perimeter_polygon.coordinates):
j = i+1
if i == length:
j = 0
next_coordinate = ground.perimeter_polygon.coordinates[j]
point_1 = GeometryHelper.coordinate_to_map_point(coordinate, city)
point_2 = GeometryHelper.coordinate_to_map_point(next_coordinate, city)
for x in range(point_1.x, point_2.x):
y = GeometryHelper.point_between_point(point_1, point_2, x).y

View File

@ -336,12 +336,3 @@ class Surface:
:param value: None or [ThermalBoundary]
"""
self._associated_thermal_boundaries = value
def shared_percentage(self, neighbour_surface):
"""
Calculate the percentage of a surface that is shared with a neighbour surface
:return: float
"""
_shared_percentage = 0
return _shared_percentage

View File

@ -24,11 +24,15 @@ class CityObject:
self._surfaces = surfaces
self._type = None
self._city_object_lower_corner = None
self._city_object_upper_corner = None
self._detailed_polyhedron = None
self._simplified_polyhedron = None
self._min_x = ConfigurationHelper().max_coordinate
self._min_y = ConfigurationHelper().max_coordinate
self._min_z = ConfigurationHelper().max_coordinate
self._max_x = ConfigurationHelper().min_coordinate
self._max_y = ConfigurationHelper().min_coordinate
self._max_z = ConfigurationHelper().min_coordinate
self._centroid = None
self._external_temperature = dict()
self._global_horizontal = dict()
@ -212,6 +216,16 @@ class CityObject:
self._city_object_lower_corner = [self._min_x, self._min_y, self._min_z]
return self._city_object_lower_corner
@property
def upper_corner(self):
"""
Get city object upper corner coordinates [x, y, z]
:return: [x,y,z]
"""
if self._city_object_upper_corner is None:
self._city_object_upper_corner = [self._max_x, self._max_y, self._max_z]
return self._city_object_upper_corner
@property
def sensors(self) -> List[Sensor]:
"""

View File

@ -14,6 +14,7 @@ from hub.city_model_structure.attributes.polygon import Polygon
from hub.city_model_structure.attributes.polyhedron import Polyhedron
from hub.helpers.location import Location
class MapPoint:
def __init__(self, x, y):
self.x = int(x)
@ -22,10 +23,12 @@ class MapPoint:
def __str__(self):
return f'({self.x}, {self.y})'
class GeometryHelper:
"""
Geometry helper class
"""
# todo: complete dictionary
srs_transformations = {
'urn:adv:crs:ETRS89_UTM32*DE_DHHN92_NH': 'epsg:25832'
}