forked from s_ranjbar/city_retrofit
Starting line information dictionary
This commit is contained in:
parent
2af1bf2e40
commit
70c0dba6bd
|
@ -64,15 +64,25 @@ class GeometryHelper:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def city_mapping(city, building_names=None, plot=False):
|
def city_mapping(city, building_names=None, plot=False):
|
||||||
|
"""
|
||||||
|
Returns a shared_information dictionary like
|
||||||
|
|
||||||
|
{
|
||||||
|
"building_name" : [{line: 0 coordinate_1: [x,y,z], coordinate_2:[x, y, z], points: 0}]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
shared_information = {}
|
||||||
if building_names is None:
|
if building_names is None:
|
||||||
building_names = [b.name for b in city.buildings]
|
building_names = [b.name for b in city.buildings]
|
||||||
x = int((city.upper_corner[0] - city.lower_corner[0]) * 0.5) + 1
|
x = int((city.upper_corner[0] - city.lower_corner[0]) * 0.5) + 1
|
||||||
y = int((city.upper_corner[1] - city.lower_corner[1]) * 0.5) + 1
|
y = int((city.upper_corner[1] - city.lower_corner[1]) * 0.5) + 1
|
||||||
city_map = [['' for _ in range(y + 1)] for _ in range(x + 1)]
|
city_map = [[{} for _ in range(y + 1)] for _ in range(x + 1)]
|
||||||
img = Image.new('RGB', (x + 1, y + 1), "black") # create a new black image
|
img = Image.new('RGB', (x + 1, y + 1), "black") # create a new black image
|
||||||
city_image = img.load() # create the pixel map
|
city_image = img.load() # create the pixel map
|
||||||
for building_name in building_names:
|
for building_name in building_names:
|
||||||
building = city.city_object(building_name)
|
building = city.city_object(building_name)
|
||||||
|
shared_information[building_name]: []
|
||||||
|
line = 0
|
||||||
for ground in building.grounds:
|
for ground in building.grounds:
|
||||||
length = len(ground.perimeter_polygon.coordinates) - 1
|
length = len(ground.perimeter_polygon.coordinates) - 1
|
||||||
for i, coordinate in enumerate(ground.perimeter_polygon.coordinates):
|
for i, coordinate in enumerate(ground.perimeter_polygon.coordinates):
|
||||||
|
@ -80,6 +90,8 @@ class GeometryHelper:
|
||||||
if i == length:
|
if i == length:
|
||||||
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}
|
||||||
|
print(line_dictionary)
|
||||||
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:
|
||||||
|
@ -102,6 +114,7 @@ class GeometryHelper:
|
||||||
neighbour.neighbours = [building]
|
neighbour.neighbours = [building]
|
||||||
elif building not in neighbour.neighbours:
|
elif building not in neighbour.neighbours:
|
||||||
neighbour.neighbours.append(building)
|
neighbour.neighbours.append(building)
|
||||||
|
line += 1
|
||||||
if plot:
|
if plot:
|
||||||
img.show()
|
img.show()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user