definitial_out_map_indoor_points(self):'''
Load the indoor data and update both the wall_matrix and the ditch_matrix.
'''# Initialize the wall_matrix# List of coordinates
coordinates =[(417,287,417,290),(414,254,414,257),(412,222,412,225),(411,209,411,211),(411,203,411,205),(567,275,567,276),(566,268,566,270),(566,261,566,263),(565,247,565,249),(563,215,563,218),(561,189,561,192),(407,238,407,245),(570,226,570,234),(464,291,466,292),(518,288,521,288),(457,187,459,187),(511,183,513,183)]
coordinates = self.sort_segments_clockwise(coordinates)
last_pointx,last_pointy=0,0
temp_no=0# Fill in the wall_matrixfor x1, y1, x2, y2 in coordinates:# apply the process of wall's calculation
points = bresenham_line(x1, y1, x2, y2)# find all the points within the straight linefor x, y in points:if0<= x <len(self.wall_matrix)and0<= y <len(
self.wall_matrix[0]):
self.wall_matrix[int(x),int(y)]=1# Remember the location of the wall.if temp_no>=1and calculate_distance(last_pointx,last_pointy,x1,y1)<=1000:
points=bresenham_line(last_pointx,last_pointy,x1,y1)for x, y in points:if0<= x <len(self.wall_matrix)and0<= y <len(
self.wall_matrix[0]):
self.wall_matrix[int(x),int(y)]=1# Remember the location of the wall.# if calculate_distance(last_pointx,last_pointy,x1,y1)>100:# print(f'Out of range:(x1:{x},y1:{y})')
temp_no=temp_no+1
last_pointx,last_pointy=x2,y2
begin_x1,begin_y1,begin_x2,begin_y2=coordinates[0]print(f'begin_x1:{begin_x1},begin_y1:{begin_y1},begin_x2:{begin_x2},begin_y2:{begin_y2}')
points = bresenham_line(begin_x1, begin_y1, x2, y2)# find all the points within the straight linefor x, y in points:if0<= x <len(self.wall_matrix)and0<= y <len(
self.wall_matrix[0]):
self.wall_matrix[int(x),int(y)]=1# Remember the location of the wall.
self.wall_matrix = self.fill_area(self.wall_matrix, target_value=1)# Update the location to the overall matrix
self.outdoor_label[self.wall_matrix ==1]=1
df=pd.DataFrame(self.wall_matrix)
df.to_csv('G:/HZXZ/Hws-Mirror-City/water_indoor/Model2_data/outdoor_data/temp_data/wall_matrix.csv', index=False)# label the location of the door
current_dir = os.path.dirname(os.path.abspath(__file__))
data_path = os.path.join(current_dir,'Model2_data/outdoor_data/out_in_map_points.xlsx')
data = pd.read_excel(data_path)for _, row in data.iterrows():# load the door coordinates and finish the transferid, x1, y1, x2, y2 = row['id'], row['x1'], row['y1'], row['x2'], row['y2']
x1, y1 = self.indoor_transfer.cad2ue(x1, y1)
x2, y2 = self.indoor_transfer.cad2ue(x2, y2)
index_x1, index_y1 = self.outdoor_transer.ue2index_model2(x1, y1,self.scaled_width,self.scaled_height)
index_x2, index_y2 = self.outdoor_transer.ue2index_model2(x2, y2,self.scaled_width,self.scaled_height)
index_x1, index_y1, index_x2, index_y2 =int(index_x1),int(index_y1),int(index_x2),int(index_y2)if index_y1 > index_y2:
tmp = index_y1
index_y1 = index_y2
index_y2 = tmp
# print(f'x1:{index_x1}, x2:{index_x2}, y1:{index_y1}, y2:{index_y2}')# label the location of the indoor doorsif index_x1 == index_x2:
self.outdoor_label[index_x1, index_y1:index_y2]=5elif index_y1 == index_y2:
self.outdoor_label[index_x1:index_x2, index_y1]=5else:
self.outdoor_label[index_x1:index_x2, index_y1:index_y2]=5# self.wall_matrix = self.fill_area(self.wall_matrix, target_value=1) # fill the circled area