working test of percentage shared by walls
This commit is contained in:
parent
28914a7402
commit
91e688d910
|
@ -12,7 +12,8 @@ from pyproj import Transformer
|
|||
from shapely.geometry import Polygon as ShapelyPolygon
|
||||
|
||||
import hub.helpers.constants as cte
|
||||
from hub.imports.geometry.helpers.geometry_helper import GeometryHelper
|
||||
from hub.helpers.geometry_helper import GeometryHelper
|
||||
from hub.imports.geometry.helpers.geometry_helper import GeometryHelper as igh
|
||||
from hub.city_model_structure.attributes.polygon import Polygon
|
||||
from hub.city_model_structure.building import Building
|
||||
from hub.city_model_structure.building_demand.surface import Surface
|
||||
|
@ -62,7 +63,7 @@ class Geojson:
|
|||
surfaces = []
|
||||
buildings = []
|
||||
for zone, surface_coordinates in enumerate(surfaces_coordinates):
|
||||
points = GeometryHelper.points_from_string(GeometryHelper.remove_last_point_from_string(surface_coordinates))
|
||||
points = igh.points_from_string(igh.remove_last_point_from_string(surface_coordinates))
|
||||
polygon = Polygon(points)
|
||||
surfaces.append(Surface(polygon, polygon, surface_type=cte.GROUND))
|
||||
buildings.append(Building(f'{name}_zone_{zone}', surfaces, year_of_construction, function))
|
||||
|
@ -106,6 +107,47 @@ class Geojson:
|
|||
polygons.append(transformed_coordinates.lstrip(' '))
|
||||
return polygons
|
||||
|
||||
@staticmethod
|
||||
def _find_wall(line_1, line_2):
|
||||
for i in range(0, 2):
|
||||
point_1 = line_1[i]
|
||||
point_2 = line_2[i]
|
||||
distance = GeometryHelper.distance_between_points(point_1, point_2)
|
||||
if distance > 1e-2:
|
||||
return False
|
||||
return True
|
||||
|
||||
def _store_shared_percentage_to_walls(self, city, city_mapped):
|
||||
for building in city.buildings:
|
||||
building_mapped = city_mapped[building.name]
|
||||
for entry in building_mapped:
|
||||
if building_mapped[entry]['shared_points'] <= 3:
|
||||
continue
|
||||
line = [building_mapped[entry]['line_start'], building_mapped[entry]['line_end']]
|
||||
neighbour_line = [building_mapped[entry]['neighbour_line_start'], building_mapped[entry]['neighbour_line_end']]
|
||||
neighbour_height = city.city_object(building_mapped[entry]['neighbour_name']).max_height
|
||||
for wall in building.walls:
|
||||
percentage = 0
|
||||
ground_line = []
|
||||
for point in wall.perimeter_polygon.coordinates:
|
||||
if point[2] < 0.5:
|
||||
ground_line.append(point)
|
||||
# todo: erase when we have no triangulation
|
||||
if len(ground_line) < 2:
|
||||
continue
|
||||
# todo: erase down to here
|
||||
if self._find_wall(line, ground_line):
|
||||
line_shared = (GeometryHelper.distance_between_points(line[0], line[1]) +
|
||||
GeometryHelper.distance_between_points(neighbour_line[0], neighbour_line[1]) -
|
||||
GeometryHelper.distance_between_points(line[1], neighbour_line[0]) -
|
||||
GeometryHelper.distance_between_points(line[0], neighbour_line[1])) / 2
|
||||
percentage = line_shared / GeometryHelper.distance_between_points(line[0], line[1])
|
||||
percentage_height = neighbour_height / building.max_height
|
||||
if percentage_height > 1:
|
||||
percentage_height = 1
|
||||
percentage = percentage * percentage_height
|
||||
wall.percentage_shared = percentage
|
||||
|
||||
@property
|
||||
def city(self) -> City:
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user