• [Model.py 02]Modification for creating terrain matrix2.


    Initialization

    		self.ditch = []  # 定义一个沟渠的列表 可以初始化
            self.ditch_inside = [] #用于定义一个矩阵,让积水点不能在这个范围内初始化
            # 920
            '''
                at present, using different no to represent objects.
                    river 1
                    road 2
                    wall 3
                    indoor 4
                    exits 5
                    pillar 6
                    ditch 7
            '''
            self.river_matrix = np.zeros((self.grid.width, self.grid.height))  # initializing river matrix
            self.road_matrix = np.zeros((self.grid.width, self.grid.height))  # initializing road matrix
            self.wall_matrix = np.zeros((self.grid.width, self.grid.height))  # initializing wall matrix
            self.indoor_matrix = np.zeros((self.grid.width, self.grid.height))  # initializing indoor matrix
            self.exits_matrix = np.zeros((self.grid.width, self.grid.height))  # initializing exits matrix
            self.pillar_matrix = np.zeros((self.grid.width, self.grid.height))  # initializing pillar matrix
            self.ditch_matrix = np.zeros((self.grid.width, self.grid.height))  # initializing ditch matrix
            self.terrain_matrix = np.zeros((self.grid.width, self.grid.height))  # initializing terrain matrix
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
            # 获取坐标文件
            road_positions_filename = f'./data/road.xlsx'
            wall_positions_filename = f'./data/east_station.xlsx'
            river_positions_filename = f'./data/river3.xlsx'
    
            # 获取偏移转化参数
            x_shifting, y_shifting, x_scale, y_scale = json_tools.read_shifting_scale()
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
            self.stream_pos = []  # 河流坐标
            self.stream_pos2=[] # added river coordinates
    
    • 1
    • 2

    Modification in initial_position

            elif pos_type == "river":
                df = pd.read_excel(file_name)
                num = df['x1'].notna().sum()
                print(pos_type, "数量:", num)
                # 坐标变化
                for i in range(num):
                    start_x, start_y = df['x1'][i], df['y1'][i]
                    start_x += x_shifting
                    start_x /= x_scale
                    start_x = round(start_x)
                    # align with roads
                    start_x = start_x -38
                    start_y += y_shifting
                    start_y /= y_scale
                    start_y = round(start_y)
                    # align with roads
                    start_y = start_y + 28
                    self.stream_pos.append((start_x, start_y))
                    if i>0:
                        '''
                            Applyiing 1 to self.river_matrix along the route 
                            from the start point(start0_x,start0_y) to end point (start_x,start_y) 
                        '''
                        self.apply_matrix_dots(start0_x, start0_y, start_x, start_y, 'river')
                    start0_x,start0_y=start_x,start_y
                num2 = df['x2'].notna().sum()
                print(pos_type, "add 数量:", num2)
                # 坐标变化
                for i in range(num2):
                    start_x, start_y = df['x2'][i], df['y2'][i]
                    start_x += x_shifting
                    start_x /= x_scale
                    start_x = round(start_x)
                    # align with roads
                    start_x = start_x -38
                    start_y += y_shifting
                    start_y /= y_scale
                    start_y = round(start_y)
                    # align with roads
                    start_y = start_y +28
                    self.stream_pos2.append((start_x, start_y))
                    if i>0:
                        '''
                            Applying 1 to self.river_matrix along the route 
                            from the start point(start0_x,start0_y) to end point (start_x,start_y) 
                        '''
                        self.apply_matrix_dots(start0_x,start0_y,start_x,start_y,'river')
                    start0_x,start0_y=start_x,start_y
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
  • 相关阅读:
    携程AI布局:三重创新引领旅游行业智能化升级
    java和vue的大学生奖学金助学金系统奖学金系统助学金系统
    jeecg 重新加载表格
    基于springboot实现教师人事档案管理系统项目【项目源码+论文说明】计算机毕业设计
    【temu】分析拼多多跨境电商Temu数据分析数据采集
    MySQL 查询条件
    SpringCloud(三)Sentinel、Seata、多级缓存
    GOPATH和Go Modules
    数据可视化分析工具DataEase
    MATLAB近红外光谱分析技术
  • 原文地址:https://blog.csdn.net/m0_51952128/article/details/133169871