Station_Map1221Update

news2024/12/22 20:46:26

1221 Polish

1. Transfer the road coordinates from the UE coordinates system into the CAD coordinates system by using the functions in the file INDEX2UE.py

坐标转换的时候,插值,取特征点(交叉点)Transfer the road coordinates, which are in the CAD coordinate system into the UE coordinate system.

  • 分散开来标注道路基准点,转换道路的坐标。也就是要让道路贴近河流,而不是河流贴近道路
  • UE and CAD refer to two different coordinate systems.
  • Key points of road from both CAD and UE coordinate systems are included in the file 高架点位对齐.xlsx

To senior Hu:

  • 道路数据是否有从CAD数据转换为UE数据(目前在model2.py文件中没有看到CAD2UE函数的调用)

To Prof Gao:

  • How to transfer from the CAD coordinate system into the UE system?

What’ the meaning of the file 高架点位对齐.xlsx if I can use the function cad2ue_plan2 in the file INDEX2UE.py

No means.

Report

Changes in the function initialMatrix

        # 初始化标签
        self.outdoor_label[self.wall_matrix == 1] = walls_label
        self.outdoor_label[self.road_matrix == 1] = roads_label
        # self.outdoor_label[self.river_matrix == 1] = river_label
        self.outdoor_label[self.ditch_matrix == 1] = ditch_label
        self.outdoor_label[soil_mask] = soil_label
        # Realize this function.
        self.initial_river()
        df=pd.DataFrame(self.outdoor_label)

Changes in the function initial_position

    def initial_position(self, file_name, x_shifting, y_shifting, x_scale, y_scale, pos_type):
        """
        参数:file_name(文件路径名字), pos_type(坐标类型)
        进行坐标转换,初始化墙、内门以及出口坐标
        """
        # 读取文件
        if pos_type == 'road':
            df = pd.read_excel(file_name, header=None)
            tuple_list = []

            # 遍历每一行
            for index, row in df.iterrows():
                tuple_row = []
                col_index = 1  # 初始列索引
                # 在每行内部,每次读取两列数据,直到读完所有列
                while col_index < len(row):
                    data1 = row.iloc[col_index]  # 第一列的数据
                    data2 = row.iloc[col_index + 1]  # 第二列的数据
                    if pd.notna(data1) and pd.notna(data2):
                        tuple_row.append((data1, data2))
                    col_index += 2  # 更新列索引,跳过已读取的两列
                if tuple_row:
                    tuple_list.append(tuple_row)
            for sublist in tuple_list:
                # 遍历每一行
                maxy = -100000
                col_index = 0
                while col_index + 1 < len(sublist):
                    # 获取两列数据
                    data1 = sublist[col_index]
                    data2 = sublist[col_index + 1]
                    start_x, start_y, end_x, end_y = data1[0], data1[1], data2[0], data2[1]

                    # end_x += x_shifting
                    # end_x /= x_scale
                    # # end_x *= self.grid.width
                    # end_x = round(end_x)
                    # end_y += y_shifting
                    # end_y /= y_scale
                    # # end_y *= self.grid.height
                    # end_y = round(end_y)
                    # start_x += x_shifting
                    # start_x /= x_scale
                    # start_x = round(start_x)
                    # start_y += y_shifting
                    # start_y /= y_scale
                    # start_y = round(start_y)
                    '''
                        Transfer the points from CAD coordinate system into UE coordinate system
                    '''
                    # apply the transfer function of cad2ue
                    x,y=start_x,start_y
                    x, y = self.outdoor_transer.cad2ue_plan2(x, y)
                    start_x, start_y = self.outdoor_transer.ue2index_model2(x, y, self.scaled_width, self.scaled_height)
                    x,y=end_x,end_y
                    x, y = self.outdoor_transer.cad2ue_plan2(x, y)
                    end_x, end_y = self.outdoor_transer.ue2index_model2(x, y, self.scaled_width, self.scaled_height)

                    self.roads.append({"start_x": start_x, "end_x": end_x, "start_y": start_y, "end_y": end_y})
                    '''
                        Applying 1 to self.road_matrix along the route
                        from the start point(star_x,star_y) to end point (end_x,end_x)
                    '''
                    self.apply_matrix_dots(start_x, start_y, end_x, end_y, 'road')
                    col_index += 1
        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:
                    '''
                        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
            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
        else:
            df = pd.read_excel(file_name)
            num = len(df['x1'])
            # print(pos_type, "数量:", num)
            # 坐标变化
            for i in range(num):
                if pos_type == 'wall':
                    start_x, start_y, end_x, end_y = df['x1'][i], df['y1'][i], df['x2'][i], df['y2'][i]
                    # end_x += x_shifting
                    # end_x /= x_scale
                    # end_x = round(end_x)
                    # end_y += y_shifting
                    # end_y /= y_scale
                    # end_y = round(end_y)
                    x,y=start_x,start_y
                    x, y = self.outdoor_transer.cad2ue_plan2(x, y)
                    start_x, start_y = self.outdoor_transer.ue2index_model2(x, y, self.scaled_width, self.scaled_height)
                    x,y=end_x,end_y
                    x, y = self.outdoor_transer.cad2ue_plan2(x, y)
                    end_x, end_y = self.outdoor_transer.ue2index_model2(x, y, self.scaled_width, self.scaled_height)
                    '''
                        Applying: 1 to self.wall_matrix along the route
                        from the start point(start_x,start_y) to end point (end_x,end_y)
                    '''
                    self.apply_matrix_dots(start_x, start_y, end_x, end_y, 'wall')

                else:
                    start_x, start_y = df['x1'][i], df['y1'][i]

                start_x += x_shifting
                start_x /= x_scale
                start_x = round(start_x)
                start_y += y_shifting
                start_y /= y_scale
                start_y = round(start_y)

                # if pos_type == 'wall':
                #     '''
                #         Applying: 1 to self.wall_matrix along the route
                #         from the start point(start_x,start_y) to end point (end_x,end_y)
                #     '''
                #     self.apply_matrix_dots(start_x, start_y, end_x, end_y, 'wall')
                if pos_type == 'indoor':
                    self.indoors.append((start_x, start_y))
                    if i > 0:
                        '''
                            Applying 1 to self.indoor_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, 'indoor')
                    start0_x, start0_y = start_x, start_y
                elif pos_type == 'exit':
                    if start_x == end_x:
                        for i in range(start_y, end_y + 1):
                            self.pos_exits.append((start_x, i))
                            # 920 apply coordinates to exits_matrix
                            self.exits_matrix[start_x][i] = 1
                    elif start_y == end_y:
                        for i in range(start_x, end_x + 1):
                            self.pos_exits.append((i, start_y))
                            # 920 apply coordinates to exits_matrix
                            self.exits_matrix[i][start_y] = 1
                    else:
                        continue
                elif pos_type == "pillar":
                    pillar_positions = {"start_x": start_x, "end_x": end_x, "start_y": start_y, "end_y": end_y}
                    self.pillars.append(pillar_positions)
                    '''
                        Applying 1 to self.pillar_matrix along the route
                        from the start point(start_x,start_y) to end point (end_x,end_y)
                    '''
                    self.apply_matrix_dots(start_x, start_y, end_x, end_y, 'pillar')
                else:
                    pass
                    # self.water_initial_pos.append((start_x, start_y))

New defined functions

  • In the file model2.py
    def fill_area(self, array, target_value=3):
        '''
            fill the circled area
        '''
        # Create a binary mask where the target_value is True
        mask = (array == target_value)

        # Fill the holes in the binary mask
        filled_mask = binary_fill_holes(mask)

        # Set the filled area back to the target_value in the original array
        array[filled_mask] = target_value
        return array

    def initial_river(self):
        valid_time = 0
        sum_time = 0
        current_dir = os.path.dirname(os.path.abspath(__file__))
        datadir = os.path.join(current_dir, './Model2_data/outdoor_data/outdoor_river')
        filenames = os.listdir(rf'{datadir}')
        # read each river points file
        for file in filenames:
            # 判断文件是否为空
            if os.path.getsize(f'{datadir}/{file}') == 0:
                continue
            # 读取txt文件
            with open(f'{datadir}/{file}', 'r') as f:
                data = f.read()

            # 将JSON格式的字符串解析为Python对象
            data = json.loads(data)
            temp_no=0
            total_start_x,total_start_y=0,0
            total_end_x,total_end_y=0,0
            # 遍历每个坐标
            for obj in data['selectedObjCoords']:
                # 获取坐标值
                x, y, z = obj['coords']['x'], obj['coords']['y'], obj['coords']['z']
                # 将UE坐标转换为索引坐标
                index_x, index_y = self.outdoor_transer.ue2index_model2(x, y, self.scaled_width, self.scaled_height)
                # print(f'转换前{x}, {y}, 转换后{index_x}, {index_y}')
                # 将z轴的值赋值给索引坐标
                if 0 <= index_x < len(self.outdoor_topographic_matrix) and 0 <= index_y < len(
                        self.outdoor_topographic_matrix[0]):
                    # self.outdoor_topographic_matrix[int(index_x), int(index_y)] = z
                    # get all the points along the straight line
                    end_x,end_y=index_x,index_y
                    total_end_x,total_end_y=index_x,index_y
                    if temp_no!=0:
                        if calculate_distance(start_x,start_y,end_x,end_y)<=50:
                            points = bresenham_line(start_x, start_y, end_x, end_y) # find all the points within the straight line
                            for x, y in points:
                                self.outdoor_label[int(x), int(y)] = 3 # Represent the river
                            valid_time += 1
                        else:
                            # find the dots that are too distant
                            print(f'({start_x},{start_y}),({end_x},{end_y})')
                    else:
                        total_start_x,total_start_y=index_x,index_y
                    start_x, start_y=index_x,index_y
                    temp_no=temp_no+1
                sum_time += 1
            # connect the last dot with the first dot. And the distance of the two dots should be within certain distance
            if calculate_distance(total_start_x,total_start_y,total_end_x,total_end_y)<=5:
                points = bresenham_line(total_start_x, total_start_y, total_end_x, total_end_y)  # find all the points within the straight line
                for x,y in points:
                    self.outdoor_label[int(x), int(y)] = 3  # Represent the river
        # For the disconnect dots due to the reason of labeling sequence. (712,172),(716,267)
        '''
            Given the coordinate of a dot and find the closest dot coordinate with the same label, 
            which is 3, in a 2D numpy array, which is `self.outdoor_label` and it has different label numbers. 
        '''
        start_x,start_y=712,172
        clos_x,clos_y=self.find_closest_dot(start_x,start_y)
        print(f'({clos_x},{clos_y})')
        points = bresenham_line(start_x, start_y, clos_x, clos_y)  # find all the points within the straight line
        for x, y in points:
            self.outdoor_label[int(x), int(y)] = 3  # Represent the river
        start_x,start_y=716,267
        clos_x,clos_y=self.find_closest_dot(start_x,start_y)
        print(f'({clos_x},{clos_y})')
        points = bresenham_line(start_x, start_y, clos_x, clos_y)  # find all the points within the straight line
        for x, y in points:
            self.outdoor_label[int(x), int(y)] = 3  # Represent the river

        # self.outdoor_label = linear_interpolation(self.outdoor_label)  # 近邻插值,只需要做一次!!
        # 对outdoor_label 补充河流的标签。 并且冲突的时候,河流的优先级最低.
        self.outdoor_label = self.fill_area(self.outdoor_label, target_value=3) # fill the circled area

        # Fill out the content of the river.
        # self.outdoor_topographic_matrix = linear_interpolation(self.outdoor_topographic_matrix)  # 近邻插值,只需要做一次!!
        # self.outdoor_topographic_matrix = cv2.GaussianBlur(self.outdoor_topographic_matrix, (7, 7), 3)

        print(f'all translate time is {sum_time}, valid translate time is {valid_time}')

    def find_closest_dot(self, x, y):
        min_dist = float('inf')
        closest_dot = None

        for i in range(self.outdoor_label.shape[0]):
            for j in range(self.outdoor_label.shape[1]):
                if self.outdoor_label[i, j] == 3:
                    dist = np.sqrt((x - i)**2 + (y - j)**2)
                    if dist < min_dist and dist>10:
                        min_dist = dist
                        closest_dot = (i, j)

        return closest_dot
  • In the file model2_utils.py
def calculate_distance(x1, y1, x2, y2):
    '''
    The function calculates the distance between two dots
    '''
    return ((x2 - x1)**2 + (y2 - y1)**2)**0.5
  • Import packages
import csv
import json
import math
import os
import numpy as np
import pandas as pd
import time
import cv2
from skimage.util import img_as_float
from skimage.segmentation import slic
from INDEX2UE import INDEX2UE
from scipy.ndimage import zoom
from model2_utils import infiltrationRate, create_custom_colormap, get_neighborhood_vectorized, bresenham_line, \
    get_coordinates_in_range, get_rectangle_coordinates, get_specific_neighbors_indices, linear_interpolation, \
    get_UE_shift,calculate_distance
from parameters import Parameters
from scipy.ndimage import binary_fill_holes, binary_dilation, generate_binary_structure
Output

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1326377.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Nature自然杂志重磅:AI复现诺奖研究一次成功只需几分钟,Coscientist科学家的好助手

《Nature》是世界上历史悠久的、最有名望的科学杂志之一&#xff0c;首版于1869年11月4日。与当今大多数科学论文杂志专一于一个特殊的领域不同&#xff0c;其是少数依然发表来自很多科学领域的一手研究论文的杂志&#xff08;其它类似的杂志有《科学》和《美国科学院学报》等&…

ES集群G1回收器,堆空间无法被回收问题

ES堆空间不足的问题&#xff0c;困扰了我有两年的时间。dump堆去分析&#xff0c;也未能分析出来&#xff0c;堆到底是被什么占用了。 我把堆空间给了31.9G&#xff0c;这是指针压缩生效的临界值&#xff0c;如果再大就指针压缩失效了。 痛苦的是&#xff0c;随着时间的增长。堆…

uniapp-uni-icons组件@click.stop失败解决~

你们好&#xff0c;我是金金金。 场景 可以看见我右侧有两个icon&#xff0c;点击的时候 会影响到折叠面板的打开&#xff0c;这让我很是苦恼&#xff0c;然后我使用了click.stop修饰符阻止事件冒泡 排查 排查之前我先贴一下代码 报错截图 可以看到找不到属性stopPropagation&…

抖音小程序开发入门

注册账号 公司和个人的都是在同一个地方注册&#xff0c;个人开发者勾选 个人开发即可 https://developer.open-douyin.com/ 在企业号&#xff0c;账号中心&#xff0c;直接邀请开发人员 发出邀请之后&#xff0c;需要被邀请人登录账号接收 调试 开发人员调试应用&#xf…

软件设计模式:六大设计原则

文章目录 前言一、开闭原则二、里氏替换原则三、依赖倒转原则四、接口隔离五、迪米特法则六、合成复用原则总结 前言 在软件开发中&#xff0c;为了提高软件系统的可维护性和可复用性&#xff0c;增加软件的可扩展性和灵活性&#xff0c;程序员要尽量根据6条原则来开发程序&am…

宝塔面板安装MySQL数据库并通过内网穿透工具实现公网远程访问

文章目录 前言1.Mysql 服务安装2.创建数据库3.安装 cpolar3.2 创建 HTTP 隧道 4.远程连接5.固定 TCP 地址5.1 保留一个固定的公网 TCP 端口地址5.2 配置固定公网 TCP 端口地址 前言 宝塔面板的简易操作性,使得运维难度降低,简化了 Linux 命令行进行繁琐的配置,下面简单几步,通…

关于研发费用资本化和费用化的理解以及在利润表与资产负债表之间的勾稽关系

关注WX公众号&#xff1a; commindtech77&#xff0c; 获得数据资产相关白皮书下载地址 回复关键字&#xff1a;推荐系统 下载《新闻资讯个性化推荐系统源码》 回复关键字&#xff1a;数据资源入表白皮书 下载《2023年数据资源入表白皮书》 原文链接&#xff1a; 关于研发…

python 常用知识点

文章目录 Python 概述内置对象、运算符、表达式、关键字Python 序列结构 Python 概述 标准库与拓展库中对象的导入与使用 &#xff08;1&#xff09;import 模块名 [ as 别名 ] //使用时用’模块名.对象名’的形式访问 &#xff08;2&#xff09;from 模块名 import 对象名 [ a…

Seata中AT模式的实现原理01-TM开启全局事务

什么是AT模式 AT模式是一种无侵入的分布式事务解决方案 保证最终一致性 是Seata默认的方式&#xff0c;在AT模式下&#xff0c;用户只需要关注自己的“业务SQL”,用户的“业务SQL”作为一阶段&#xff0c;Seata框架会自动的生成事务的二阶段提交和回滚 AT模式的机制 AT模式其…

生活中的物理2——人类迷惑行为(用笔扎手)

1实验 材料 笔、手 实验 1、先用手轻轻碰一下笔尖&#xff08;未成年人须家长监护&#xff09; 2、再用另一只手碰碰笔尾 你发现了什么&#xff1f;&#xff1f; 2发现 你会发现碰笔尖的手明显比碰笔尾的手更痛 你想想为什么 3原理 压强f/s 笔尖的面积明显比笔尾的小 …

AI技术迅猛发展,视频智能化给人类带来了哪些便利?

随着AI技术的迅猛发展&#xff0c;视频智能化也逐渐普及。在我们常见的生产工作和日常生活中&#xff0c;视频智能化都为人类带来了许多便利。今天小编就和大家探讨一下智能化监控带来了哪些便利。 1、安全监控 视频智能化可以实现智能安防监控&#xff0c;例如智慧安防系统Ea…

FLASH闪存的读取、擦除、编程

一、stm32寄存器地址介绍 二、FLASH简介 &#xff08;1&#xff09;STM32F1系列的FLASH包含程序存储器、系统存储器和选项字节三个部分&#xff0c;通过闪存存储器接口可以对程序存储器和选项字节进行擦除和编程 &#xff08;2&#xff09; 读写FLASH的用途&#xff1a;利用程…

Android Studio打包有哪些优势

大家好&#xff0c;现在移动应用程序的快速发展&#xff0c;开发者需要一个强大又可靠的开发环境来创建和打包高质量的 Android 应用程序。Android Studio 是一款由 Google 官方开发的 Android 应用程序开发环境&#xff0c;提供了许多的优势和便利&#xff0c;那究竟都有哪些优…

LeetCode刷题--- 括号生成

个人主页&#xff1a;元清加油_【C】,【C语言】,【数据结构与算法】-CSDN博客 个人专栏 力扣递归算法题 http://t.csdnimg.cn/yUl2I 【C】 http://t.csdnimg.cn/6AbpV 数据结构与算法 http://t.csdnimg.cn/hKh2l 前言&#xff1a;这个专栏主要讲述递归递归、搜…

【自用】Ubuntu20.4从Vivado到ddr200t运行HelloWorld

【自用】Ubuntu20.4新系统从输入法到ddr200t运行HelloWorld 一、编辑bashrc二、Vivado2022.2安装三、编译蜂鸟E203自测样例1. 环境准备2. 下载e203_hbirdv2工程文件3. 尝试编译自测案例1. 安装RISC-V GNU工具链2. 编译测试样例 4. 用vivado为FPGA生成mcs文件1.准备RTL2.生成bit…

界面控件DevExpress WPF Dock组件,轻松创建类Visual Studio窗口界面!

本文主要为大家介绍DevExpress WPF控件中的Dock组件&#xff0c;它能帮助用户轻松创还能受Microsoft Visual Studio启发的Dock窗口界面。 P.S&#xff1a;DevExpress WPF拥有120个控件和库&#xff0c;将帮助您交付满足甚至超出企业需求的高性能业务应用程序。通过DevExpress …

社交网络分析(汇总)

这里写自定义目录标题 写在最前面社交网络分析系列文章汇总目录 提纲问题一、社交网络相关定义和概念提纲问题1. 社交网络、社交网络分析&#xff1b;2. 六度分隔理论、贝肯数、顿巴数&#xff1b;3. 网络中的数学方法&#xff1a;马尔科夫过程和马尔科夫链、平均场理论、自组织…

EasyUiAutotest 项目目录设置及说明

一、前置说明 清晰的项目目录结构非常重要的&#xff0c;它能够为项目提供结构化、易维护、易理解的环境。 二、目录设置及说明 项目目录结构如下&#xff1a; EasyUiAutotest ├───atme # me&#xff0c;供个人使用的目录&#xff0c;与整体项目无关&#xff0c;存…

ubuntu 20.04安装一系列软件

1&#xff09;安装下载的包的指令&#xff1a; sudo dpkg -i xxx.deb 2&#xff09;通用指令&#xff1a; sudo apt-get install xxxx 3&#xff09;更新和升级软件包&#xff08;遇到Unable to locate packge等问题先尝试这个指令&#xff09;&#xff1a; sudo apt-get up…

如何取消iCloud订阅,这里有非常明细的步骤

iCloud是存储文件、照片和备份的好方法&#xff0c;但每个用户获得的5GB免费iCloud存储空间往往不够。如果你使用iCloud Drive在设备之间存储和传输大量文件&#xff0c;你可能需要购买更多的iCloud存储。我们将向你展示如何在iPhone设置中更改iCloud存储计划或取消iCloud订阅。…