forked from s_ranjbar/city_retrofit
Starting line information dictionary
This commit is contained in:
parent
70c0dba6bd
commit
4caea94271
|
@ -441,26 +441,3 @@ class Building(CityObject):
|
||||||
for usage in internal_zone.usages:
|
for usage in internal_zone.usages:
|
||||||
_usage = f'{_usage}{usage.name}_{usage.percentage} '
|
_usage = f'{_usage}{usage.name}_{usage.percentage} '
|
||||||
return _usage.rstrip()
|
return _usage.rstrip()
|
||||||
|
|
||||||
def identify_shared_walls(self):
|
|
||||||
"""
|
|
||||||
Identifies which building' walls adjoin the neighbouring building and saves that information in the
|
|
||||||
corresponding surfaces
|
|
||||||
"""
|
|
||||||
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
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ class GeometryHelper:
|
||||||
j = 0
|
j = 0
|
||||||
next_coordinate = ground.perimeter_polygon.coordinates[j]
|
next_coordinate = ground.perimeter_polygon.coordinates[j]
|
||||||
line_dictionary = {"line": line, "coordinate_1": coordinate, "coordinate_2":next_coordinate, "points": 0}
|
line_dictionary = {"line": line, "coordinate_1": coordinate, "coordinate_2":next_coordinate, "points": 0}
|
||||||
print(line_dictionary)
|
print(building_name, line_dictionary['line'])
|
||||||
point = GeometryHelper.coordinate_to_map_point(coordinate, city)
|
point = GeometryHelper.coordinate_to_map_point(coordinate, city)
|
||||||
distance = GeometryHelper.distance_between_points(coordinate, next_coordinate)
|
distance = GeometryHelper.distance_between_points(coordinate, next_coordinate)
|
||||||
if distance == 0:
|
if distance == 0:
|
||||||
|
@ -101,7 +101,7 @@ class GeometryHelper:
|
||||||
for k in range(0, int(distance)):
|
for k in range(0, int(distance)):
|
||||||
x = MapPoint(point.x + (delta_x * k), point.y + (delta_y * k)).x
|
x = MapPoint(point.x + (delta_x * k), point.y + (delta_y * k)).x
|
||||||
y = MapPoint(point.x + (delta_x * k), point.y + (delta_y * k)).y
|
y = MapPoint(point.x + (delta_x * k), point.y + (delta_y * k)).y
|
||||||
if city_map[x][y] == '':
|
if city_map[x][y] == {}:
|
||||||
city_map[x][y] = building.name
|
city_map[x][y] = building.name
|
||||||
city_image[x, y] = (100, 0, 0)
|
city_image[x, y] = (100, 0, 0)
|
||||||
elif city_map[x][y] != building.name:
|
elif city_map[x][y] != building.name:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user