1223西站坐标更新

2023-12-24 02:36
文章标签 更新 坐标 1223 西站

本文主要是介绍1223西站坐标更新,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1223 西站坐标更新

1.Update for the station’s location

    def initial_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 coordinatescoordinates = [(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,0temp_no=0# Fill in the wall_matrixfor x1, y1, x2, y2 in coordinates:# apply the process of wall's calculationpoints = bresenham_line(x1, y1, x2, y2)  # find all the points within the straight linefor x, y in points:if 0 <= x < len(self.wall_matrix) and 0 <= y < len(self.wall_matrix[0]):self.wall_matrix[int(x), int(y)] = 1  # Remember the location of the wall.if temp_no>=1 and calculate_distance(last_pointx,last_pointy,x1,y1)<=1000:points=bresenham_line(last_pointx,last_pointy,x1,y1)for x, y in points:if 0 <= x < len(self.wall_matrix) and 0 <= 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+1last_pointx,last_pointy=x2,y2begin_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:if 0 <= x < len(self.wall_matrix) and 0 <= 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 matrixself.outdoor_label[self.wall_matrix == 1] = 1df=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 doorcurrent_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_y1index_y1 = index_y2index_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

新增函数

    def calculate_midpoint(self,segment):return ((segment[0] + segment[2]) / 2, (segment[1] + segment[3]) / 2)def calculate_centroid(self,segments):x_sum, y_sum = 0, 0for segment in segments:midpoint = self.calculate_midpoint(segment)x_sum += midpoint[0]y_sum += midpoint[1]return x_sum / len(segments), y_sum / len(segments)def calculate_angle(self,centroid, point):return math.atan2(point[1] - centroid[1], point[0] - centroid[0])def sort_segments_clockwise(self,segments):centroid = self.calculate_centroid(segments)return sorted(segments, key=lambda segment: self.calculate_angle(centroid, self.calculate_midpoint(segment)))

更细的函数

    def showOutdoorImg(self, outdoor_acc_water_matrix):"""opencv可视化降雨量矩阵结果input: rainfall_matrixoutput: null"""# 获取矩阵中的最大值和对应的下标max_value = np.max(outdoor_acc_water_matrix)max_index = np.argmax(outdoor_acc_water_matrix)# 将一维下标转换为二维下标max_index_2d = np.unravel_index(max_index, outdoor_acc_water_matrix.shape)print(f'the largest water logging is {max_value}, the index is {max_index_2d}')mat = np.transpose(np.copy(outdoor_acc_water_matrix))[::-1]# 归一化矩阵# mat = cv2.normalize(mat, None, 200, 250, cv2.NORM_MINMAX, dtype=cv2.CV_8UC3)mat = mat / 300 * 250mat[mat > 250] = 250mat[mat < 30] = 30mat = mat.astype(np.uint8)mat = cv2.cvtColor(mat, cv2.COLOR_RGB2BGR)# 自定义颜色映射表custom_colormap = create_custom_colormap()# 将矩阵映射到蓝色色域image = cv2.applyColorMap(mat, custom_colormap)label = np.transpose(self.outdoor_label)[::-1]outdoor_acc_water_matrix = np.transpose(outdoor_acc_water_matrix)[::-1]image[outdoor_acc_water_matrix < 2] = [255, 255, 255]  # 积水为0设置为白色image[label == 1] = [0,255,255]  # 墙体设置为黄色image[label == 2] = 0  # 路面设置为黑色image[label == 3] = [0, 0, 255]  # 河流部分设置为(30,144,255)image[label == 5] = [0, 255, 0]  # 河流部分设置为(30,144,255)# image[label == 4] = [0, 255, 0]image[label == 9] = [25, 74, 230]image = cv2.resize(image, None, None, 1, 1, cv2.INTER_NEAREST)# 插入西站图片# west_station_img = cv2.imread('Model2_data/outdoor_data/west_station.png')# x, y = int(108*self.resize_scale), int(54*self.resize_scale)# west_station_img = cv2.resize(west_station_img, None, None, self.resize_scale, self.resize_scale, cv2.INTER_NEAREST)# image[y:y + west_station_img.shape[0], x:x + west_station_img.shape[1]] = west_station_imgcv2.imwrite(f'result/outdoor_imgs/time_stamp{self.time_stamp}.png', image)cv2.imwrite(f'Model2_data/outdoor_data/temp_data/time_stamp{self.time_stamp}.png', image)if self.__debug_mode:# 显示图像cv2.imshow("OutdoorImage", image)cv2.waitKey(500)# cv2.destroyAllWindows()
    def initialMatrix(self):'''水体系统,初步生成室外降水 渗透 地势三个matrix0.土壤1.墙体2.道路3.河流4.沟渠5.室内外映射点位9.易涝点初步生成室内地势matrix1.ditch2.wall3.Stair4.RoadStair'''# 初始化outdoor_label矩阵soil_label = 0walls_label = 1roads_label = 2river_label = 3ditch_label = 4infinite = np.inf  # 设置较大的值代表河流的渗透是无穷的infiltration_standard = 2  # 渗透量国标# 初始化地势图中各处的高度walls_height = np.infroads_height = 0river_height = -1ditch_height = -10# 室内初始化self.indoor_topographic_matrix[self.indoor_label == 1] = ditch_heightself.indoor_topographic_matrix[self.indoor_label == 2] = infinite# path = 'Model2_data/outdoor_data/'# np.save(path+'road_matrix_test.npy', self.road_matrix)# road_matrix = np.load(path+'road_matrix_test.npy')# 室外初始化# 对标签矩阵作转换,转换到UE矩阵中去# self.wall_matrix = self.outdoor_transer.four_point_transform(self.wall_matrix)# self.river_matrix = self.outdoor_transer.four_point_transform(self.river_matrix)# self.ditch_matrix = self.outdoor_transer.four_point_transform(self.ditch_matrix)# self.road_matrix = self.outdoor_transer.four_point_transform(self.road_matrix)# 初始化降雨矩阵soil_mask = (self.wall_matrix == 0) & (self.road_matrix == 0) & (self.river_matrix == 0) & (self.ditch_matrix == 0)self.rainfall_matrix[self.wall_matrix == 1] = 0self.rainfall_matrix[self.wall_matrix == 0] = 1# UE转为地势矩阵&初始化特殊地势矩阵self.initial_topographic_matrix()# print(f'topographic_matrix non zero points num is {np.count_nonzero(self.outdoor_topographic_matrix)}')self.outdoor_topographic_matrix[self.wall_matrix == 1] = walls_height# self.outdoor_topographic_matrix[self.road_matrix == 1] = roads_height# self.outdoor_topographic_matrix[self.river_matrix == 1] = river_heightself.outdoor_topographic_matrix[self.ditch_matrix == 1] = ditch_height# 西站坐标初始化# random_values = np.random.randint(-10, 10, size=np.count_nonzero(soil_mask))# self.outdoor_topographic_matrix[soil_mask] = random_values# 初始化标签self.outdoor_label[soil_mask] = soil_label# Updated way of labeling both the station and the ditchself.initial_out_map_indoor_points()self.outdoor_label[self.road_matrix == 1] = roads_label# self.outdoor_label[self.river_matrix == 1] = river_labelself.outdoor_label[self.ditch_matrix == 1] = ditch_label# self.outdoor_label[self.wall_matrix == 1] = walls_label# Realize this function.self.initial_river()df=pd.DataFrame(self.outdoor_label)df.to_csv('G:/HZXZ/Hws-Mirror-City/water_indoor/Model2_data/outdoor_data/temp_data/outdoor_label.csv', index=False)print(f'temporary numbers: {np.unique(self.outdoor_label)}')self.initial_prone_waterlogging_points()# 室内外映射点位初始化# for index in range(len(self.outdoor_map_indoor) // 2):#     for (i, j) in self.outdoor_map_indoor[f'outdoor_point{index + 1}']:#         self.outdoor_topographic_matrix[i][j] = 0#         self.outdoor_label[i][j] = 5pass

Final Output

在这里插入图片描述

这篇关于1223西站坐标更新的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/530294

相关文章

Ubuntu 24.04 LTS怎么关闭 Ubuntu Pro 更新提示弹窗?

《Ubuntu24.04LTS怎么关闭UbuntuPro更新提示弹窗?》Ubuntu每次开机都会弹窗提示安全更新,设置里最多只能取消自动下载,自动更新,但无法做到直接让自动更新的弹窗不出现,... 如果你正在使用 Ubuntu 24.04 LTS,可能会注意到——在使用「软件更新器」或运行 APT 命令时,

poj3468(线段树成段更新模板题)

题意:包括两个操作:1、将[a.b]上的数字加上v;2、查询区间[a,b]上的和 下面的介绍是下解题思路: 首先介绍  lazy-tag思想:用一个变量记录每一个线段树节点的变化值,当这部分线段的一致性被破坏我们就将这个变化值传递给子区间,大大增加了线段树的效率。 比如现在需要对[a,b]区间值进行加c操作,那么就从根节点[1,n]开始调用update函数进行操作,如果刚好执行到一个子节点,

hdu1394(线段树点更新的应用)

题意:求一个序列经过一定的操作得到的序列的最小逆序数 这题会用到逆序数的一个性质,在0到n-1这些数字组成的乱序排列,将第一个数字A移到最后一位,得到的逆序数为res-a+(n-a-1) 知道上面的知识点后,可以用暴力来解 代码如下: #include<iostream>#include<algorithm>#include<cstring>#include<stack>#in

hdu1689(线段树成段更新)

两种操作:1、set区间[a,b]上数字为v;2、查询[ 1 , n ]上的sum 代码如下: #include<iostream>#include<algorithm>#include<cstring>#include<stack>#include<queue>#include<set>#include<map>#include<stdio.h>#include<stdl

hdu 1754 I Hate It(线段树,单点更新,区间最值)

题意是求一个线段中的最大数。 线段树的模板题,试用了一下交大的模板。效率有点略低。 代码: #include <stdio.h>#include <string.h>#define TREE_SIZE (1 << (20))//const int TREE_SIZE = 200000 + 10;int max(int a, int b){return a > b ? a :

AI行业应用(不定期更新)

ChatPDF 可以让你上传一个 PDF 文件,然后针对这个 PDF 进行小结和提问。你可以把各种各样你要研究的分析报告交给它,快速获取到想要知道的信息。https://www.chatpdf.com/

GIS图形库更新2024.8.4-9.9

更多精彩内容请访问 dt.sim3d.cn ,关注公众号【sky的数孪技术】,技术交流、源码下载请添加微信:digital_twin123 Cesium 本期发布了1.121 版本。重大新闻,Cesium被Bentley收购。 ✨ 功能和改进 默认启用 MSAA,采样 4 次。若要关闭 MSAA,则可以设置scene.msaaSamples = 1。但是通过比较,发现并没有多大改善。

JavaFX应用更新检测功能(在线自动更新方案)

JavaFX开发的桌面应用属于C端,一般来说需要版本检测和自动更新功能,这里记录一下一种版本检测和自动更新的方法。 1. 整体方案 JavaFX.应用版本检测、自动更新主要涉及一下步骤: 读取本地应用版本拉取远程版本并比较两个版本如果需要升级,那么拉取更新历史弹出升级控制窗口用户选择升级时,拉取升级包解压,重启应用用户选择忽略时,本地版本标志为忽略版本用户选择取消时,隐藏升级控制窗口 2.

记录每次更新到仓库 —— Git 学习笔记 10

记录每次更新到仓库 文章目录 文件的状态三个区域检查当前文件状态跟踪新文件取消跟踪(un-tracking)文件重新跟踪(re-tracking)文件暂存已修改文件忽略某些文件查看已暂存和未暂存的修改提交更新跳过暂存区删除文件移动文件参考资料 咱们接着很多天以前的 取得Git仓库 这篇文章继续说。 文件的状态 不管是通过哪种方法,现在我们已经有了一个仓库,并从这个仓

消除安卓SDK更新时的“https://dl-ssl.google.com refused”异常的方法

消除安卓SDK更新时的“https://dl-ssl.google.com refused”异常的方法   消除安卓SDK更新时的“https://dl-ssl.google.com refused”异常的方法 [转载]原地址:http://blog.csdn.net/x605940745/article/details/17911115 消除SDK更新时的“