Movatterモバイル変換


[0]ホーム

URL:


CN111145303B - A method of drawing vector map line symbols with pointed arrows in consideration of line width consistency - Google Patents

A method of drawing vector map line symbols with pointed arrows in consideration of line width consistency
Download PDF

Info

Publication number
CN111145303B
CN111145303BCN201911365157.3ACN201911365157ACN111145303BCN 111145303 BCN111145303 BCN 111145303BCN 201911365157 ACN201911365157 ACN 201911365157ACN 111145303 BCN111145303 BCN 111145303B
Authority
CN
China
Prior art keywords
value
line
line width
vector
points
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911365157.3A
Other languages
Chinese (zh)
Other versions
CN111145303A (en
Inventor
乐松山
温永宁
陈旻
闾国年
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing Normal University
Original Assignee
Nanjing Normal University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing Normal UniversityfiledCriticalNanjing Normal University
Priority to CN201911365157.3ApriorityCriticalpatent/CN111145303B/en
Publication of CN111145303ApublicationCriticalpatent/CN111145303A/en
Application grantedgrantedCritical
Publication of CN111145303BpublicationCriticalpatent/CN111145303B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Images

Classifications

Landscapes

Abstract

Translated fromChinese

本发明公开了一种顾及线宽一致性的矢量地图线符号尖角形箭头绘制方法,包括以下步骤:首先初始化矢量线要素,指定屏幕坐标系线宽,指定起点和终点处是否绘制尖角形箭头。接着,按照坐标转换规则将屏幕线宽转换为世界坐标系的线宽,对矢量线要素进行三角化操作,并在起点和终点处进行膨胀操作。然后,构建顾及线宽一致性的GPU状态协议,在CPU中组装协议内容并传递到GPU中。最终,在GPU中获取状态协议,在起点和终点处进行尖角形箭头的腐蚀操作,实现保持线宽一致的绘制。本发明通过构建面向尖角形箭头线符号绘制的状态协议,利用结构化的状态协议,实现在地图缩放过程中不改变线宽、不重新三角化,完成线要素起点、终点处的尖角形箭头绘制。

Figure 201911365157

The invention discloses a method for drawing a pointed arrow of a vector map line symbol in consideration of line width consistency, which comprises the following steps: first, initializing vector line elements, specifying the line width of a screen coordinate system, and specifying whether to draw a pointed arrow at a starting point and an ending point. Then, convert the screen line width to the line width of the world coordinate system according to the coordinate transformation rules, triangulate the vector line elements, and perform dilation at the start and end points. Then, build a GPU state protocol that takes into account line width consistency, assemble the protocol content in the CPU and pass it to the GPU. Finally, the state protocol is obtained in the GPU, and the erosion operation of the pointed arrow is performed at the starting point and the ending point, so as to achieve drawing with consistent line width. The present invention constructs a state protocol for the drawing of pointed arrow line symbols, utilizes the structured state protocol, realizes the drawing of pointed arrows at the start and end points of line elements without changing the line width and without re-triangulation during the zooming process of the map .

Figure 201911365157

Description

Translated fromChinese
顾及线宽一致性的矢量地图线符号尖角形箭头绘制方法A method for drawing sharp arrows in vector map line symbols taking into account line width consistency

技术领域Technical Field

本发明涉及数字地图制图领域和地理信息系统领域的矢量地图线符号尖角形箭头绘制方法,尤其涉及一种顾及线宽一致性的矢量地图线符号尖角形箭头绘制方法。The invention relates to a method for drawing a vector map line symbol sharp-angled arrow in the field of digital map making and geographic information system, and in particular to a method for drawing a vector map line symbol sharp-angled arrow taking into account line width consistency.

背景技术Background Art

数字地图制图是将现实世界中各种空间信息以地图的方式呈现出来,点、线和面要素是地图中最基础的三种表达结构,由此主导了点、线和面符号化方法。通过各种不同的点符号、线符号和面符号,能够将空间实体的分布状况、关联关系、相互作用等信息形象化的传递给读图者。为了能够支撑读图者快速理解地图、准确获取空间信息,地图符号的绘制是最为关键的因素。在现实地理世界中,广泛存在着“方向”型的空间信息,如风吹的方向、河流的方向、道路的行驶方向等。为了能够将此类方向型的信息传递给读图者,带有尖角形箭头的线符号是一种常用的方法。Digital mapping is to present various spatial information in the real world in the form of maps. Points, lines and surface elements are the three most basic expression structures in maps, which dominate the point, line and surface symbolization methods. Through various point symbols, line symbols and surface symbols, the distribution status, associations, interactions and other information of spatial entities can be conveyed to the readers in a visual way. In order to support readers to quickly understand maps and accurately obtain spatial information, the drawing of map symbols is the most critical factor. In the real geographical world, there is a wide range of "directional" spatial information, such as the direction of wind, the direction of rivers, the direction of roads, etc. In order to convey this kind of directional information to readers, line symbols with sharp arrows are a common method.

为了能够绘制带有尖角形箭头的线符号,当前主要有两种方法:一种是基于软件绘制的方法,一种是基于GPU硬件的方法。前者广泛应用于现有各种二维地图平台上,主要是通过纯软件的方式来操作像素着色,典型的方法有GDI+,Cairo,AGG等。例如,论文《面向GIS的矢量线状符号填充算法研究》(张海泉,潘懋,吴焕萍,等.《地理与地理信息科学》,2004,20(04):11-14.),给出了一种基于GDI+的纯软件绘制方法来表达矢量线要素。该种方法严格依赖于矢量线的屏幕坐标和屏幕宽度,当地图缩放时,需要不断的进行重新计算和绘制,严重降低了地图显示的效率。针对此效率低下的问题,后续的研究大多数集中于如何用硬件加速的方法,即后者基于GPU硬件的方法来实现矢量线符号的绘制。In order to draw line symbols with sharp arrows, there are currently two main methods: one is a software-based method and the other is a GPU-based method. The former is widely used on various existing two-dimensional map platforms, mainly operating pixel shading through pure software. Typical methods include GDI+, Cairo, AGG, etc. For example, the paper "Research on Vector Line Symbol Filling Algorithm for GIS" (Zhang Haiquan, Pan Mao, Wu Huanping, et al. "Geography and Geographic Information Science", 2004, 20(04):11-14.) gives a pure software drawing method based on GDI+ to express vector line features. This method strictly depends on the screen coordinates and screen width of the vector line. When the map is scaled, it needs to be recalculated and drawn continuously, which seriously reduces the efficiency of map display. In response to this inefficiency problem, most subsequent studies focus on how to use hardware acceleration methods, that is, the latter GPU-based methods to achieve the drawing of vector line symbols.

基于GPU硬件绘制的方法主要是研究如何通过GPU着色器(Shader)来绘制线符号。代表性的方法如论文《A function-based linear map symbol building and renderingmethod using shader language》(Yue SS,Yang JS,Chen M,等.《International Journalof Geographical Information Science》,2016,30(2):143-16)提出了一种利用OpenGLShader 来构建线符号并用GPU绘制。该方法依赖于一个颜色二维数组来表达符号结构,虽然能够通过数组标记来表达和绘制虚线符号,但整个方法中只是针对固定地图比例尺的绘制,对于线宽的一致性问题完全没有涉及;此论文方法也只针对不带箭头的线符号,如何处理带尖角形箭头的线符号未有涉及。The method based on GPU hardware drawing mainly studies how to draw line symbols through GPU shaders. Representative methods such as the paper "A function-based linear map symbol building and rendering method using shader language" (Yue SS, Yang JS, Chen M, et al. "International Journal of Geographical Information Science", 2016, 30 (2): 143-16) proposed a method of using OpenGL Shader to build line symbols and draw them with GPU. This method relies on a two-dimensional array of colors to express the symbol structure. Although it is possible to express and draw dashed line symbols through array markers, the entire method is only for drawing fixed map scales, and the consistency of line width is not involved at all; this paper method is also only for line symbols without arrows, and how to deal with line symbols with sharp arrows is not involved.

而论文《一种基于屏幕的三维地图线状符号渲染方法》(刘君妍,陈雅茜,高亦远,等.《地球信息科学学报》,2018,20(8):1047-1054)提出了将矢量线要素映射成为纹理数据,通过纹理数据来绘制线;该方法主要是针对线要素与地形的融合,线要素的线宽处理明确是随着地图缩放而变化的。此外名称为“基于GPU的地图线形符号绘制方法及系统”(申请号201310125110.6)的中国专利,名为“基于GPU的宽度渐变线型地图符号绘制方法”(申请号201610015703.0)的中国专利,名为“基于GPU的颜色渐变线型地图符号绘制方法”(申请号201610016561.X),都是在分析GPU绘制矢量线要素难点的基础上,提出了用Shader着色器来绘制线符号的方法。但是这些方法都是针对固定比例尺的线符号绘制,当地图比例尺变化时,为了保持线宽不变,前述方法都需要重新三角化和绘制。反复不断的三角化对绘制效率具有明显的影响,由此造成了地图的缩放交互仍然存在效率瓶颈。并且由于尖角形箭头的特殊性,已有GPU硬件绘制方法均未提出明确的解决方案。The paper "A Screen-based 3D Map Linear Symbol Rendering Method" (Liu Junyan, Chen Yaqian, Gao Yiyuan, et al. Journal of Geo-Information Science, 2018, 20(8): 1047-1054) proposed mapping vector line elements into texture data and drawing lines through texture data; this method is mainly aimed at the fusion of line elements and terrain, and the line width processing of line elements is clearly changed with the zoom of the map. In addition, the Chinese patent named "GPU-based Map Linear Symbol Drawing Method and System" (application number 201310125110.6), the Chinese patent named "GPU-based Width Gradient Linear Map Symbol Drawing Method" (application number 201610015703.0), and the Chinese patent named "GPU-based Color Gradient Linear Map Symbol Drawing Method" (application number 201610016561.X) all proposed methods of using Shader shaders to draw line symbols based on the analysis of the difficulties of GPU drawing vector line elements. However, these methods are all for drawing line symbols at a fixed scale. When the map scale changes, in order to keep the line width unchanged, the above methods need to be re-triangulated and re-drawn. Repeated triangulation has a significant impact on drawing efficiency, which results in an efficiency bottleneck in map zooming interaction. And due to the particularity of sharp-angled arrows, existing GPU hardware drawing methods have not proposed a clear solution.

整体而言,现有方法主要是面向静态线宽绘制,当地图比例尺缩放时,需要重新计算和绘制;另外,基于GPU硬件加速的带尖角形箭头的线要素绘制也未见公开方法。本发明提出了一种顾及线宽一致性的矢量地图线要素尖角形箭头绘制方法,其可以实现: (1)随着地图比例尺缩放保持线宽一致,(2)矢量线要素不需要重新进行三角化,(3) 尖角形箭头能够与线要素一起绘制。因为GPU的绘制依赖于三角面片,当一个矢量线被三角化成三角形序列后,GPU只能拿到坐标和颜色,整个绘制是无状态的(即无法区分哪里是起始点、哪里是终止点、哪里是箭头等)。为了能够在GPU中绘制尖角形箭头,本发明的核心就是构建了独特的GPU状态协议,从而驱动CPU-GPU协同工作,实现随着地图缩放线宽保持一致的尖角形箭头绘制。In general, the existing methods are mainly aimed at drawing static line widths, and when the map scale is scaled, recalculation and drawing are required; in addition, there is no public method for drawing line elements with sharp arrows based on GPU hardware acceleration. The present invention proposes a method for drawing sharp arrows for vector map line elements that takes into account line width consistency, which can achieve: (1) keeping the line width consistent as the map scale is scaled, (2) vector line elements do not need to be re-triangulated, and (3) sharp arrows can be drawn together with line elements. Because GPU drawing relies on triangular facets, when a vector line is triangulated into a triangle sequence, the GPU can only get the coordinates and colors, and the entire drawing is stateless (that is, it is impossible to distinguish where the starting point is, where the end point is, where the arrow is, etc.). In order to be able to draw sharp arrows in the GPU, the core of the present invention is to construct a unique GPU state protocol, thereby driving the CPU-GPU to work together and achieve the drawing of sharp arrows with consistent line width as the map is scaled.

发明内容Summary of the invention

本发明的目的是在GPU绘制环境下,针对带有尖角形箭头的地图线符号线宽一致性绘制需求,突破传统要么不管线宽一致性、要么反复三角化的问题,提供一种能够实现在地图缩放过程中不改变线宽、不重新三角化,实现线要素起点、终点处的尖角形箭头绘制的顾及线宽一致性的矢量地图线符号尖角形箭头绘制方法。The purpose of the present invention is to provide a method for drawing vector map line symbols with sharp arrows in a GPU drawing environment, which can achieve the drawing of sharp arrows at the starting and end points of line elements without changing the line width or re-triangulating during map zooming, and take into account the line width consistency, in order to meet the line width consistency drawing requirements of map line symbols with sharp arrows, break through the traditional problems of either ignoring the line width consistency or repeatedly triangulating.

技术方案:一种顾及线宽一致性的矢量地图线符号尖角形箭头绘制方法,包括下列步骤:Technical solution: A method for drawing a vector map line symbol sharp arrow with line width consistency in mind, comprising the following steps:

步骤1、对矢量线要素的坐标序列进行初始化,设置以像素为单位的屏幕线宽,设置起点和终点处是否绘制尖角形箭头;Step 1, initialize the coordinate sequence of the vector line element, set the screen line width in pixels, and set whether to draw sharp arrows at the start and end points;

步骤2、构建矢量线要素的世界坐标系和屏幕坐标系之间的转换规则,通过此规则将屏幕线宽转换为世界坐标系的线宽,根据此世界坐标系线宽:顺序遍历矢量线要素的每个坐标,由线生成三角形集合,其中每个三角形的每个顶点都具有沿线走向的U值和垂直线走向的V值,并且每个顶点还具有一个缩放方向向量D值;对矢量线要素的起点和终点分别进行膨胀操作和协议标记;Step 2, construct the conversion rule between the world coordinate system and the screen coordinate system of the vector line element, and convert the screen line width into the line width of the world coordinate system through this rule. According to the line width of the world coordinate system: traverse each coordinate of the vector line element sequentially, and generate a triangle set from the line, where each vertex of each triangle has a U value along the line and a V value perpendicular to the line, and each vertex also has a scaling direction vector D value; perform expansion operation and protocol marking on the starting point and end point of the vector line element respectively;

步骤3、组装GPU着色器的状态协议:该状态协议包括两个层次,一个是顶点层,包括U值、V值、缩放方向D值,另一个是结构层,包括最大线宽M值、地图比例缩放S值、起点标记CB、终点标记CE;Step 3: Assemble the state protocol of GPU shader: The state protocol includes two levels, one is the vertex layer, including U value, V value, and scaling direction D value, and the other is the structure layer, including the maximum line width M value, map scale S value, starting point mark CB, and end point mark CE;

步骤4、在CPU中获取初始的世界坐标系线宽和地图比例尺缩放系数,并分别按照状态协议中的M值、S值、CB值和CE值传递到GPU中,由此在GPU着色器中解析状态协议中的U、V、D、M、S、CB、CE值,动态计算当前尖角形箭头需要绘制的像素位置,并最终完成绘制。Step 4. Obtain the initial world coordinate system line width and map scale scaling factor in the CPU, and pass them to the GPU according to the M value, S value, CB value, and CE value in the state protocol, respectively. Then, parse the U, V, D, M, S, CB, and CE values in the state protocol in the GPU shader, dynamically calculate the pixel position where the current pointed arrow needs to be drawn, and finally complete the drawing.

进一步的,所述步骤2中沿线走向的U值根据每个顶点沿着线要素的距离计算获得,其中起点扩张出来的两个顶点U值均为0,终点扩张出来的两个顶点U值均为整条线的长度除以线宽,其他点扩张出来的两个顶点U值均根据长度累积值除以线宽获得;垂直线走向的V值根据每个顶点向两侧扩张的距离计算获得,线要素上的每个点,其扩张出来的两个顶点位于线走向左侧的V为1,位于右侧的0;顶点缩放方向的D值是一个二维向量,指明了扩张出来的每个顶点与原始点之间的连接方向,并且不是一个归一化的向量,D值二维向量的长度是根据扩张顶点与原始点之间的距离计算获得的。Furthermore, the U value along the line in step 2 is calculated based on the distance of each vertex along the line element, wherein the U values of the two vertices expanded from the starting point are both 0, the U values of the two vertices expanded from the end point are both the length of the entire line divided by the line width, and the U values of the two vertices expanded from other points are obtained by dividing the cumulative length by the line width; the V value of the perpendicular line direction is calculated based on the distance expanded to both sides of each vertex, and for each point on the line element, the V value of the two expanded vertices located on the left side of the line direction is 1, and the V value of those located on the right side is 0; the D value in the vertex scaling direction is a two-dimensional vector, which indicates the connection direction between each expanded vertex and the original point, and is not a normalized vector. The length of the D value two-dimensional vector is calculated based on the distance between the expanded vertex and the original point.

进一步的,所述步骤2中:Furthermore, in step 2:

矢量线要素的起点膨胀操作:矢量线要素的起点逆于线走向扩张一个线宽,再垂直于线走向分别向两侧扩张一个线宽,由此形成两个点;矢量线要素的起点顺着线走向扩张一个线宽,再垂直于线走向分别向两侧扩张一个线宽,由此再形成两个点;此四个点构成以两个线宽为边长的正方形,也就是起点处的膨胀正方形;The expansion operation of the starting point of the vector line element: the starting point of the vector line element expands one line width against the direction of the line, and then expands one line width to both sides perpendicular to the direction of the line, thereby forming two points; the starting point of the vector line element expands one line width along the direction of the line, and then expands one line width to both sides perpendicular to the direction of the line, thereby forming two more points; these four points form a square with two line widths as the side length, which is the expanded square at the starting point;

矢量线要素的终点膨胀操作:矢量线要素的终点逆着线走向扩张一个线宽,再垂直于线走向分别向两侧扩张一个线宽,由此形成两个点;矢量线要素的终点顺着线走向扩张一个线宽,再垂直于线走向分别向两侧扩张一个线宽,由此再形成两个点;此四个点构成以两个线宽为边长的正方形,也就是终点处的膨胀正方形;The end point expansion operation of a vector line element: the end point of a vector line element expands by one line width against the direction of the line, and then expands by one line width perpendicular to the direction of the line to form two points; the end point of a vector line element expands by one line width along the direction of the line, and then expands by one line width perpendicular to the direction of the line to form two more points; these four points form a square with two line widths as the side length, which is the expanded square at the end point;

进一步的,所述步骤2中:Furthermore, in step 2:

矢量线要素的起点标记:起点膨胀正方形中逆着线方向膨胀出来的两个点,其U值均为-2.0;起点膨胀正方形中顺着线方向膨胀出来的两个点,其U值均为-1.0;起点膨胀正方形中位于线走向右侧的两个点V值为0,左侧的两个点V值为1;The starting point mark of the vector line element: the two points in the starting point expansion square that expand against the direction of the line have a U value of -2.0; the two points in the starting point expansion square that expand along the direction of the line have a U value of -1.0; the two points on the right side of the line in the starting point expansion square have a V value of 0, and the two points on the left have a V value of 1;

矢量线要素的终点标记:终点膨胀正方形中逆着线方向膨胀出来的两个点,其U值均为-10.0;终点膨胀正方形中顺着线方向膨胀出来的两个点,其U值均为-11.0;终点膨胀正方形中位于线走向右侧的两个点V值为0,左侧的两个点V值为1;End point mark of vector line element: the two points in the expansion square of the end point that expand against the direction of the line have a U value of -10.0; the two points in the expansion square of the end point that expand along the direction of the line have a U value of -11.0; the two points on the right side of the line in the expansion square of the end point have a V value of 0, and the two points on the left have a V value of 1;

区分起点和终点:线要素中既不是起点也不是终点部分的U值均为大于等于0,起点和终点部分的膨胀正方形U值均小于0,其中起点处的U值大于等于-2.0,而终点处的U值小于-2.0;Distinguish the starting point and the end point: the U value of the part of the line element that is neither the starting point nor the end point is greater than or equal to 0, and the U value of the expansion square of the starting point and the end point is less than 0, where the U value at the starting point is greater than or equal to -2.0, and the U value at the end point is less than -2.0;

进一步的,所述步骤3中最大线宽M值是根据步骤2中计算获得的世界坐标系的线宽;地图比例缩放S值是随着地图比例尺缩放动态更新的比例值;起点标记CB值和终点标记CE值是对应于是否绘制尖角形箭头的浮点数值,小于0表示不绘制尖角形箭头,大于等于0则表示绘制尖角形箭头;状态协议按照U值、V值、D值、M值、S值、 CB值、CE值进行组织,其中U值和V值是一维浮点数、D值是二维浮点数、M值和 S值是一维浮点数、CB值和CE值也是一维浮点数,将U值、V值、D值按序组织成四维向量,将M值、S值、CB值、CE值按序组织成四维向量,最终形成的状态协议由两个向量构成:U-V-D四维向量和M-S-CB-CE四维向量,顾及线宽一致性的矢量地图线符号尖角形箭头绘制必须严格遵从此协议,在CPU和GPU之间进行消息传递时也必须严格依照此协议进行消息组装。Furthermore, the maximum line width M value in step 3 is the line width of the world coordinate system calculated in step 2; the map scale S value is a scale value dynamically updated as the map scale is scaled; the starting point mark CB value and the end point mark CE value are floating point values corresponding to whether to draw a sharp arrow, less than 0 indicates not to draw a sharp arrow, and greater than or equal to 0 indicates drawing a sharp arrow; the state protocol is organized according to U value, V value, D value, M value, S value, CB value, and CE value, wherein U value and V value are one-dimensional floating point numbers, D value is a two-dimensional floating point number, M value and The S value is a one-dimensional floating point number, and the CB value and CE value are also one-dimensional floating point numbers. The U value, V value, and D value are organized into a four-dimensional vector in sequence. The M value, S value, CB value, and CE value are organized into a four-dimensional vector in sequence. The final state protocol is composed of two vectors: the U-V-D four-dimensional vector and the M-S-CB-CE four-dimensional vector. The drawing of vector map line symbols with sharp arrows that take into account line width consistency must strictly comply with this protocol. When transmitting messages between the CPU and GPU, message assembly must also be strictly in accordance with this protocol.

进一步的,所述步骤4中,对起点和终点进行尖角形箭头腐蚀操作:Furthermore, in step 4, a sharp-angled arrow erosion operation is performed on the starting point and the end point:

A.将起点处的膨胀正方形的四个点U值统一加上1.0,从而形成一个0.0到-1.0的区间;将终点处的膨胀正方形的四个点U值统一加上10.0,从而形成一个0.0到-1.0的区间;A. Add 1.0 to the U value of the four points of the expanded square at the starting point, thus forming an interval from 0.0 to -1.0; add 10.0 to the U value of the four points of the expanded square at the end point, thus forming an interval from 0.0 to -1.0;

B.根据V值将膨胀正方形分为上下两个部分,如果V值小于等于0.5则处于下半部分,如果V值大于0.5则处于上半部分;B. Divide the expanded square into two parts according to the V value. If the V value is less than or equal to 0.5, it is in the lower part. If the V value is greater than 0.5, it is in the upper part.

B1.上半部分:利用-0.5的斜率来控制需要腐蚀的区域:V值大于U值乘以斜率-0.5则进行腐蚀;B1. Upper part: Use the slope of -0.5 to control the area that needs to be corroded: if the V value is greater than the U value multiplied by the slope of -0.5, corrosion will be carried out;

B2.下半部分:利用0.5的斜率来控制需要腐蚀的区域:V值小于U值乘以斜率0.5则进行腐蚀。B2. Lower part: Use a slope of 0.5 to control the area that needs to be corroded: Corrosion is performed if the V value is less than the U value multiplied by the slope of 0.5.

本发明的方法可以充分利用GPU硬件加速的绘制性能,突破GPU仅依靠坐标和颜色的无状态绘制局限,通过定制合理的状态协议,将矢量线的走向信息、线宽信息、起点和终点信息、地图缩放比例信息、尖角形箭头信息在CPU和GPU之间传递。通过两个四维向量的组合,能够有效的组装状态协议;按照U-V-D-M-S-CB-CE的结构能够方便的实现状态内容的获取,从而在GPU的着色器中进行保持线宽一致的尖角形箭头绘制。相比于传统的方法,本发明能够在不重复三角化的基础上,定制清晰的状态协议,实现随着地图比例尺的缩放进行线宽一致的尖角形箭头绘制,从而提升地图的绘制效率和效果。The method of the present invention can make full use of the drawing performance of GPU hardware acceleration, break through the limitation of GPU stateless drawing that only relies on coordinates and colors, and transmit the direction information, line width information, starting point and end point information, map zoom ratio information, and sharp-angled arrow information of the vector line between the CPU and the GPU by customizing a reasonable state protocol. Through the combination of two four-dimensional vectors, the state protocol can be effectively assembled; according to the structure of U-V-D-M-S-CB-CE, the acquisition of state content can be conveniently realized, so that the drawing of sharp-angled arrows with consistent line width can be performed in the shader of the GPU. Compared with the traditional method, the present invention can customize a clear state protocol on the basis of non-repeated triangulation, and realize the drawing of sharp-angled arrows with consistent line width as the map scale is scaled, thereby improving the efficiency and effect of map drawing.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1是本发明方法的流程示意图;Fig. 1 is a schematic flow diagram of the method of the present invention;

图2是状态协议的基本结构;Figure 2 is the basic structure of the state protocol;

图3是U值、V值和D值的说明,以及基于状态协议的矢量线要素三角化方法说明;FIG3 is an illustration of U value, V value and D value, and an illustration of a method for triangulating vector line features based on a state protocol;

图4是线要素起点处、终点处的膨胀方法说明;Figure 4 is an illustration of the expansion method at the starting point and the end point of the line element;

图5是以终点处为例说明在GPU如何进行尖角形箭头的腐蚀方法说明;FIG5 is a diagram showing how to perform corrosion of a sharp-angled arrow on a GPU, taking the end point as an example;

图6是M值和S值的说明,以及地图缩放后线宽处理的方法说明,其中深色填充部分为真实绘制的线宽,外层虚线部分为原始不处理前的绘制区域(即一开始三角化的结果);Figure 6 is an explanation of the M value and S value, as well as an explanation of the line width processing method after the map is zoomed, where the dark filled part is the actual drawn line width, and the outer dotted line part is the original drawing area before processing (i.e., the result of the initial triangulation);

图7是利用本发明的方法绘制结果示意图,(a)为小比例尺双向尖角形箭头,(b)为大比例尺双向尖角形箭头端头,(c)为小比例尺终点尖角形箭头,(d)为大比例尺终点尖角形箭头端头,(e)为小比例尺起点尖角形箭头,(f)为大比例尺起点尖角形箭头端头。Figure 7 is a schematic diagram of the results drawn using the method of the present invention, (a) is a small-scale bidirectional pointed arrow, (b) is the end of a large-scale bidirectional pointed arrow, (c) is a small-scale end point pointed arrow, (d) is the end of a large-scale end point pointed arrow, (e) is a small-scale starting point pointed arrow, and (f) is the end of a large-scale starting point pointed arrow.

具体实施方式DETAILED DESCRIPTION

下面结合附图和具体实施例对本发明的技术方案做进一步说明。The technical solution of the present invention is further described below in conjunction with the accompanying drawings and specific embodiments.

图1为本发明方法的流程图。该方法包括以下步骤:首先对待绘制的矢量线要素进行初始化,指定需要在屏幕上呈现的线宽(像素单位),指定起点和终点处是否绘制尖角形箭头,并确定矢量线要素的世界坐标系和屏幕坐标系之间的转换规则。接着,按照坐标转换规则将屏幕线宽转换为世界坐标系的线宽,并在世界坐标系下对矢量线要素进行三角化操作,同时在起点和终点处进行膨胀操作。然后,按照所构建的顾及线宽一致性的GPU状态协议,在CPU中获取地图缩放比例系数、初始线宽大小、起点终点尖角形箭头标记等信息,并利用状态协议传递到GPU中。最终,在GPU中获取状态协议内容,在起点和终点处进行尖角形箭头的腐蚀操作,实现保持线宽一致的尖角形箭头绘制。FIG1 is a flow chart of the method of the present invention. The method comprises the following steps: first, the vector line element to be drawn is initialized, the line width (in pixel units) to be presented on the screen is specified, whether a sharp arrow is drawn at the starting point and the end point is specified, and the conversion rule between the world coordinate system and the screen coordinate system of the vector line element is determined. Next, the screen line width is converted to the line width of the world coordinate system according to the coordinate conversion rule, and the vector line element is triangulated in the world coordinate system, and an expansion operation is performed at the starting point and the end point. Then, according to the constructed GPU state protocol that takes into account the consistency of line width, the map zoom factor, the initial line width, the sharp arrow mark of the starting point and the end point, and other information are obtained in the CPU, and are passed to the GPU using the state protocol. Finally, the state protocol content is obtained in the GPU, and the sharp arrow is corroded at the starting point and the end point to achieve the drawing of the sharp arrow with consistent line width.

在GPU绘制环境下,三角化是将矢量线要素进行线符号化绘制的关键。GPU着色器获取三角形序列,通过三角形的坐标和颜色来在屏幕上呈现待绘制对象。本质上,GPU 的绘制流水线是一种无状态的过程,矢量线的线宽相关信息无法从CPU直接传递给 GPU。对于带有尖角形箭头的线符号而言,其需要沿着线的走向、按照确定的线宽进行绘制。基于此需求,本发明设计了一种面向带有尖角形箭头的线符号保持线宽一致性绘制的状态协议。CPU中需要按照此状态协议组织信息,GPU中需要按照此状态协议解析信息。In the GPU drawing environment, triangulation is the key to symbolizing vector line elements. The GPU shader obtains a triangle sequence and presents the object to be drawn on the screen through the coordinates and colors of the triangles. In essence, the GPU drawing pipeline is a stateless process, and the line width-related information of the vector line cannot be directly transmitted from the CPU to the GPU. For line symbols with sharp arrows, they need to be drawn along the direction of the line and according to a determined line width. Based on this requirement, the present invention designs a state protocol for drawing line symbols with sharp arrows while maintaining line width consistency. Information needs to be organized in the CPU according to this state protocol, and information needs to be parsed in the GPU according to this state protocol.

状态协议包含两个层面,一个是顶点层的U值,V值和D值,另一个是结构层的 M值、S值、CB值和CE值,如图2所示;U值、V值、D值、M值、S值、CB值和 CE值的内涵和计算方法在后续几个段落阐述。U值和V值分别是两个浮点型float数值, D值是一个二维向量,其具有X和Y方向的分量D(x)和D(y)。M值、S值、CB值和 CE值是四个浮点型的数值。U-V-D三个值被组装成一个四维向量,M、S、CB、CE四个值被组装成一个四维向量。因此,面向尖角形箭头的线宽一致性绘制,CPU和GPU 之间的信息传递就依赖于这两个四维向量的组合。之所以将U-V-D组装成一个四维向量、将M-S-CB-CE组装成一个三维向量,是为了在CPU-GPU信息传递过程中尽可能减少信息交互的次数,批量进行传递。The state protocol contains two levels, one is the U value, V value and D value of the vertex layer, and the other is the M value, S value, CB value and CE value of the structure layer, as shown in Figure 2; the connotation and calculation method of the U value, V value, D value, M value, S value, CB value and CE value are explained in the following paragraphs. The U value and the V value are two floating-point values, respectively, and the D value is a two-dimensional vector with components D(x) and D(y) in the X and Y directions. The M value, S value, CB value and CE value are four floating-point values. The three values of U-V-D are assembled into a four-dimensional vector, and the four values of M, S, CB and CE are assembled into a four-dimensional vector. Therefore, for the line width consistency drawing of the pointed arrow, the information transmission between the CPU and the GPU depends on the combination of these two four-dimensional vectors. The reason why U-V-D is assembled into a four-dimensional vector and M-S-CB-CE is assembled into a three-dimensional vector is to minimize the number of information interactions during the CPU-GPU information transmission process and to transmit them in batches.

对于U-V-D值而言,在图3中给出了相关的计算方法。U-V-D值是附加在每个扩展顶点上的。扩展顶点是指依据矢量线要素上的任一点,按照垂直与线走向的方向分别向两边进行扩张后得到的顶点;其中,扩张距离是线宽的一半(世界坐标系的线宽)。扩张顶点可以分为左侧点和右侧点(根据沿线走向来确定)。如图3所示,所有右侧顶点的V值都是0,所有左侧顶点的V值都是1。任一个扩张顶点的U值都是通过计算其所关联的点与起始点之间的距离得到。起始点的两个扩张顶点的U值都是0,终止点的两个扩张顶点的U值都是整个矢量线的长度除以线宽。起始点与终止点中间的任一点都是按照累积距离除以线宽得到。D值是表明扩张顶点方向的二维向量,该向量是依据扩张顶点与关联点获得。需要注意的是,D向量不能进行归一化,其向量长度就是扩张顶点与关联点之间的长度。As for the U-V-D value, the relevant calculation method is given in Figure 3. The U-V-D value is attached to each extended vertex. An extended vertex refers to a vertex obtained by expanding to both sides according to the direction perpendicular to the line direction based on any point on the vector line element; among them, the expansion distance is half of the line width (the line width of the world coordinate system). The extended vertices can be divided into left points and right points (determined according to the direction along the line). As shown in Figure 3, the V value of all right vertices is 0, and the V value of all left vertices is 1. The U value of any extended vertex is obtained by calculating the distance between the point associated with it and the starting point. The U values of the two extended vertices at the starting point are both 0, and the U values of the two extended vertices at the ending point are the length of the entire vector line divided by the line width. Any point between the starting point and the ending point is obtained by dividing the cumulative distance by the line width. The D value is a two-dimensional vector indicating the direction of the extended vertex, which is obtained based on the extended vertex and the associated point. It should be noted that the D vector cannot be normalized, and its vector length is the length between the extended vertex and the associated point.

特别的,对于矢量线要素两个端点的U-V-D值而言,起点和终点处均需要进行膨胀处理,如图4所示。在图4中的左半部分,也就是起点位置处:首先逆着线走向扩张一个线宽,再垂直于线走向分别向两侧扩张一个线宽,形成相应的两个膨胀点(左侧点1 和右侧点1);接着沿着线走向扩张一个线宽,再垂直于线走向分别向两侧扩张一个线宽,形成相应的另外两个膨胀点(左侧点2和右侧点2)。通过左侧点1、右侧点1、左侧点 2和右侧点2这个四个点,构成了起点处的膨胀正方形。通过正方形的对角线进行划分,形成两个三角形传递到GPU中。类似的,图4中同样给出了终点出的膨胀方法,起点和终点的膨胀正方形是对称的:In particular, for the U-V-D values of the two endpoints of the vector line element, both the starting point and the end point need to be expanded, as shown in Figure 4. In the left half of Figure 4, that is, at the starting point: first expand a line width against the direction of the line, and then expand a line width perpendicular to the direction of the line to both sides, forming two corresponding expansion points (point 1 on the left and point 1 on the right); then expand a line width along the direction of the line, and then expand a line width perpendicular to the direction of the line to both sides, forming two corresponding expansion points (point 2 on the left and point 2 on the right). The four points of left point 1, right point 1, left point 2 and right point 2 form the expansion square at the starting point. Divide the square by the diagonal line to form two triangles and pass them to the GPU. Similarly, Figure 4 also gives the expansion method at the end point, and the expansion squares at the starting point and the end point are symmetrical:

(1)起点处膨胀正方形的左侧点1和右侧点1,其U值均为-2.0;起点处膨胀正方形的左侧点2和右侧点2,其U值均为-1.0。另外,左侧点1和左侧点2的V值都为1,右侧点1和右侧点2的点V值都为0。四个点的D值都是各自与起点的连接向量。(1) The U values of the left and right points 1 of the expanded square at the starting point are both -2.0; the U values of the left and right points 2 of the expanded square at the starting point are both -1.0. In addition, the V values of the left and right points 1 are both 1, and the V values of the right and right points 1 are both 0. The D values of the four points are the connection vectors between each of them and the starting point.

(2)终点处膨胀正方形的左侧点1和右侧点1,其U值均为-11.0;终点处膨胀正方形的左侧点2和右侧点2,其U值均为-12.0。另外,左侧点1和左侧点2的V值都为 1,右侧点1和右侧点2的点V值都为0。四个点的D值都是各自与起点的连接向量。(2) The U values of the left and right points 1 of the expanded square at the end point are both -11.0; the U values of the left and right points 2 of the expanded square at the end point are both -12.0. In addition, the V values of the left and right points 1 are both 1, and the V values of the right and right points 1 are both 0. The D values of the four points are the connection vectors between each of them and the starting point.

通过GPU状态协议中的U-V-D值能够判断出起点和终点的位置。既不是起点也不是终点的U值大于等于0;起点的U值小于等-1.0并且大于等于-2.0;终点的U值小于等于-10.0并且大于等于-11.0。The U-V-D value in the GPU status protocol can be used to determine the position of the start and end points. The U value of a point that is neither the start nor the end point is greater than or equal to 0; the U value of the start point is less than or equal to -1.0 and greater than or equal to -2.0; the U value of the end point is less than or equal to -10.0 and greater than or equal to -11.0.

在能够判断何处是起点、何处是终点的基础上,图5给出了基于GPU状态协议的终点处尖角形箭头腐蚀方法。首先将膨胀正方形的四个点U值统一加上10.0,从而形成一个0.0到-1.0的区间。再根据V值将膨胀正方形分为上下两个部分,如果V值小于等于0.5则处于下半部分,反之则处于上半部分。在上半部分,利用-0.5的斜率来控制需要腐蚀的区域:V值大于U值乘以斜率就需要进行腐蚀,即图5中的区域1。在下半部分,利用0.5的斜率来控制需要腐蚀的区域:V值小于U值乘以斜率就需要进行腐蚀,即图5中的区域2。图5中给出了终点处的工艺,在起点的工艺与之类似,不同之处在于U值需要统一加上1.0,从而也形成一个0.0到-1.0的区间。On the basis of being able to judge where the starting point and the end point are, FIG5 shows the method of corroding the sharp arrow at the end point based on the GPU state protocol. First, the U values of the four points of the expanded square are uniformly added with 10.0, thereby forming an interval from 0.0 to -1.0. Then the expanded square is divided into two parts according to the V value. If the V value is less than or equal to 0.5, it is in the lower half, otherwise it is in the upper half. In the upper half, the slope of -0.5 is used to control the area that needs to be corroded: if the V value is greater than the U value multiplied by the slope, corrosion is required, that is, area 1 in FIG5. In the lower half, the slope of 0.5 is used to control the area that needs to be corroded: if the V value is less than the U value multiplied by the slope, corrosion is required, that is, area 2 in FIG5. FIG5 shows the process at the end point, and the process at the starting point is similar to it, except that the U value needs to be uniformly added with 1.0, thereby also forming an interval from 0.0 to -1.0.

对于M-S-CB-CE值而言,M值是在初始地图比例尺下显示的最大线宽的值,S值是相对于初始地图比例尺的缩放系数,CB值和CE值是指起点和终点是否绘制尖角形箭头。如果CB值小于0则在起点处不绘制尖角形箭头,如果CB值大于等于0则在起点处绘制尖角形箭头。同样的,如果CE值小于0则在终点处不绘制尖角形箭头,如果CE 值大于等于0则在终点处绘制尖角形箭头。For the M-S-CB-CE value, the M value is the maximum line width displayed at the initial map scale, the S value is the scaling factor relative to the initial map scale, and the CB and CE values refer to whether to draw sharp arrows at the start and end points. If the CB value is less than 0, no sharp arrow is drawn at the start point, and if the CB value is greater than or equal to 0, a sharp arrow is drawn at the start point. Similarly, if the CE value is less than 0, no sharp arrow is drawn at the end point, and if the CE value is greater than or equal to 0, a sharp arrow is drawn at the end point.

如图6所示,在GPU中解析状态协议里面的M-S-CB-CE值,利用以下公式重新计算任一扩张顶点的坐标:X=D(x)*M*(1.0-S)/2.0,Y=D(y)*M*(1.0-S)/2.0。D(x)和 D(y)分别表示顶点方向向量的X分量和Y分量。在GPU中结合D值、M值和S值,动态计算每个点真正需要绘制的位置。在图6中外部虚线部分为初始比例尺下需要绘制的区域,中间深色填充部分为缩放比例尺之后需要绘制的区域。可以看出初始区域大,大比例尺区域小;因为在大比例尺下,矢量线要素的扩张顶点直接转换为屏幕坐标后会比初始比例尺大,所以通过D向量和M-S值来控制扩张顶点向内收缩,从而达到一致线宽的绘制效果。As shown in Figure 6, the M-S-CB-CE value in the state protocol is parsed in the GPU, and the coordinates of any expanded vertex are recalculated using the following formula: X = D(x)*M*(1.0-S)/2.0, Y = D(y)*M*(1.0-S)/2.0. D(x) and D(y) represent the X component and Y component of the vertex direction vector, respectively. In the GPU, the D value, M value, and S value are combined to dynamically calculate the position where each point actually needs to be drawn. In Figure 6, the outer dotted line part is the area that needs to be drawn at the initial scale, and the dark filled part in the middle is the area that needs to be drawn after the scale is scaled. It can be seen that the initial area is large and the large scale area is small; because at a large scale, the expanded vertex of the vector line element will be larger than the initial scale after being directly converted to screen coordinates, so the D vector and M-S value are used to control the expansion vertex to shrink inward, so as to achieve a drawing effect with consistent line width.

在图7中给出了两个不同地图比例尺,不同尖角形箭头的绘制效果。(a)为小比例尺双向尖角形箭头,(b)为大比例尺双向尖角形箭头端头,(c)为小比例尺终点尖角形箭头,(d)为大比例尺终点尖角形箭头端头,(e)为小比例尺起点尖角形箭头,(f)为大比例尺起点尖角形箭头端头;其中,(a)、(c)、(e)都是小比例尺绘制,(b)、(d)、(f)都是大比例尺绘制。(a)、(b)是双向尖角形箭头的绘制效果,(c)、(d)是终点尖角形箭头的绘制效果,(e)、(f)是起点尖角形箭头绘制效果。通过交叉对比可以看出小比例尺和大比例尺的绘制效果在线宽方面是一致的。Figure 7 shows the drawing effects of different pointed arrows at two different map scales. (a) is a small-scale bidirectional pointed arrow, (b) is a large-scale bidirectional pointed arrow head, (c) is a small-scale end-point pointed arrow, (d) is a large-scale end-point pointed arrow head, (e) is a small-scale starting-point pointed arrow, and (f) is a large-scale starting-point pointed arrow head; among them, (a), (c), and (e) are all drawn at a small scale, and (b), (d), and (f) are all drawn at a large scale. (a) and (b) are the drawing effects of bidirectional pointed arrows, (c) and (d) are the drawing effects of end-point pointed arrows, and (e) and (f) are the drawing effects of starting-point pointed arrows. Through cross-comparison, it can be seen that the drawing effects of small and large scales are consistent in line width.

实施例:Example:

相比于传统计算机可视化领域中的线绘制,地图绘制中的尖角形箭头符号需要考虑地图比例尺的变化。GPU绘制环境下,仅通过三角形集合的坐标和颜色来控制绘制流程,无法满足保持线宽一致性的需求。所以本发明设计了一种GPU状态协议,通过此协议将线宽相关的信息打包传递给GPU,在GPU中能够有序解析这些信息;同时在起点和终点处定制了独特的膨胀和腐蚀方式,从而达到顾及线宽一致性的矢量地图线符号尖角形箭头绘制。Compared with line drawing in the field of traditional computer visualization, the sharp arrow symbol in map drawing needs to consider the change of map scale. In the GPU drawing environment, the drawing process is controlled only by the coordinates and colors of the triangle set, which cannot meet the requirement of maintaining line width consistency. Therefore, the present invention designs a GPU state protocol, through which the information related to line width is packaged and transmitted to the GPU, and the GPU can parse this information in an orderly manner; at the same time, unique expansion and erosion methods are customized at the starting point and the end point, so as to achieve the drawing of vector map line symbol sharp arrows that takes into account the consistency of line width.

以下是利用OpenGL Shader给出了本发明的实施例:The following is an embodiment of the present invention using OpenGL Shader:

(1)GPU状态协议结构(1) GPU State Protocol Structure

Figure SMS_1
Figure SMS_1

Figure SMS_2
Figure SMS_2

(2)CPU状态协议结构(2)CPU status protocol structure

Figure SMS_3
Figure SMS_3
.

Claims (4)

Translated fromChinese
1.一种顾及线宽一致性的矢量地图线符号尖角形箭头绘制方法,其特征在于,包括下列步骤:1. A method for drawing a vector map line symbol sharp arrow with consideration of line width consistency, characterized in that it comprises the following steps:步骤1、对矢量线要素的坐标序列进行初始化,设置以像素为单位的屏幕线宽,设置起点和终点处是否绘制尖角形箭头;Step 1, initialize the coordinate sequence of the vector line element, set the screen line width in pixels, and set whether to draw sharp arrows at the start and end points;步骤2、构建矢量线要素的世界坐标系和屏幕坐标系之间的转换规则,通过此规则将屏幕线宽转换为世界坐标系的线宽,根据此世界坐标系线宽:顺序遍历矢量线要素的每个坐标,由线生成三角形集合,其中每个三角形的每个顶点都具有沿线走向的U值和垂直线走向的V值,并且每个顶点还具有一个缩放方向向量D值;对矢量线要素的起点和终点分别进行膨胀操作和协议标记;Step 2, construct the conversion rule between the world coordinate system and the screen coordinate system of the vector line element, and convert the screen line width into the line width of the world coordinate system through this rule. According to the line width of the world coordinate system: traverse each coordinate of the vector line element sequentially, and generate a triangle set from the line, where each vertex of each triangle has a U value along the line and a V value perpendicular to the line, and each vertex also has a scaling direction vector D value; perform expansion operation and protocol marking on the starting point and end point of the vector line element respectively;所述矢量线要素的起点膨胀操作:矢量线要素的起点逆着线走向扩张一个线宽,再垂直于线走向分别向两侧扩张一个线宽,由此形成两个点;矢量线要素的起点顺着线走向扩张一个线宽,再垂直于线走向分别向两侧扩张一个线宽,由此再形成两个点;此四个点构成以两个线宽为边长的正方形,即起点处的膨胀正方形;The starting point expansion operation of the vector line element: the starting point of the vector line element expands by one line width against the direction of the line, and then expands by one line width to both sides perpendicular to the direction of the line, thereby forming two points; the starting point of the vector line element expands by one line width along the direction of the line, and then expands by one line width to both sides perpendicular to the direction of the line, thereby forming two more points; these four points form a square with two line widths as sides, that is, the expanded square at the starting point;所述矢量线要素的终点膨胀操作:矢量线要素的终点逆着线走向扩张一个线宽,再垂直于线走向分别向两侧扩张一个线宽,由此形成两个点;矢量线要素的终点顺着线走向扩张一个线宽,再垂直于线走向分别向两侧扩张一个线宽,由此再形成两个点;此四个点构成以两个线宽为边长的正方形,即终点处的膨胀正方形;The end point expansion operation of the vector line element: the end point of the vector line element expands by one line width against the line direction, and then expands by one line width perpendicular to the line direction to both sides, thereby forming two points; the end point of the vector line element expands by one line width along the line direction, and then expands by one line width perpendicular to the line direction to both sides, thereby forming two more points; these four points form a square with two line widths as sides, that is, the expanded square at the end point;所述矢量线要素的起点协议标记:起点膨胀正方形中逆着线方向膨胀出来的两个点,其U值均为-2.0;起点膨胀正方形中顺着线方向膨胀出来的两个点,其U值均为-1.0;起点膨胀正方形中位于线走向右侧的两个点V值为0,左侧的两个点V值为1;The starting point protocol mark of the vector line element: the two points in the starting point expansion square that expand against the direction of the line have a U value of -2.0; the two points in the starting point expansion square that expand along the direction of the line have a U value of -1.0; the two points on the right side of the line in the starting point expansion square have a V value of 0, and the two points on the left side have a V value of 1;所述矢量线要素的终点协议标记:终点膨胀正方形中逆着线方向膨胀出来的两个点,其U值均为-10.0;终点膨胀正方形中顺着线方向膨胀出来的两个点,其U值均为-11.0;终点膨胀正方形中位于线走向右侧的两个点V值为0,左侧的两个点V值为1;The endpoint protocol mark of the vector line element: the two points in the end expansion square that expand against the direction of the line have a U value of -10.0; the two points in the end expansion square that expand along the direction of the line have a U value of -11.0; the two points on the right side of the line in the end expansion square have a V value of 0, and the two points on the left side have a V value of 1;区分起点和终点:线要素中既不是起点也不是终点部分的U值均为大于等于0,起点和终点部分的膨胀正方形U值均小于0,其中起点处的U值大于等于-2.0,而终点处的U值小于-2.0;Distinguish the starting point and the end point: the U value of the part of the line element that is neither the starting point nor the end point is greater than or equal to 0, and the U value of the expansion square of the starting point and the end point is less than 0, where the U value at the starting point is greater than or equal to -2.0, and the U value at the end point is less than -2.0;步骤3、组装GPU着色器的状态协议:该状态协议包括两个层次,一个是顶点层,包括U值、V值、缩放方向D值,另一个是结构层,包括最大线宽M值、地图比例缩放S值、起点标记CB值、终点标记CE值;Step 3, assemble the state protocol of GPU shader: the state protocol includes two levels, one is the vertex layer, including U value, V value, scaling direction D value, the other is the structure layer, including the maximum line width M value, map scale S value, starting point mark CB value, end point mark CE value;A.最大线宽M值是世界坐标系的线宽;A. The maximum line width M value is the line width of the world coordinate system;B.地图比例缩放S值是随着地图比例尺缩放动态更新的比例值;B. Map scale S value is the scale value that is dynamically updated as the map scale is scaled;C.起点标记CB值和终点标记CE值:是对应于是否绘制尖角形箭头的浮点数值,小于0表示不绘制尖角形箭头,大于等于0则表示绘制尖角形箭头;C. The starting point mark CB value and the end point mark CE value: are floating point values corresponding to whether to draw a sharp arrow. If it is less than 0, it means not to draw a sharp arrow, and if it is greater than or equal to 0, it means to draw a sharp arrow.D.状态协议:按照U值、V值、D值、M值、S值、CB值、CE值进行组织,其中U值和V值是一维浮点数、D值是二维浮点数、M值和S值是一维浮点数、CB值和CE值也是一维浮点数,将U值、V值、D值按序组织成四维向量,将M值、S值、CB值、CE值按序组织成四维向量,最终形成的状态协议由两个向量构成:U-V-D四维向量和M-S-CB-CE四维向量;D. State protocol: Organize according to U value, V value, D value, M value, S value, CB value, and CE value, where U value and V value are one-dimensional floating point numbers, D value is a two-dimensional floating point number, M value and S value are one-dimensional floating point numbers, and CB value and CE value are also one-dimensional floating point numbers. Organize U value, V value, and D value into four-dimensional vectors in sequence, and organize M value, S value, CB value, and CE value into four-dimensional vectors in sequence. The final state protocol consists of two vectors: U-V-D four-dimensional vector and M-S-CB-CE four-dimensional vector;步骤4、在CPU中获取初始的世界坐标系线宽和地图比例尺缩放系数,并分别按照状态协议中的M值、S值、CB值和CE值传递到GPU中,由此在GPU着色器中解析状态协议中的U值、V值、D值、M值、S值、CB值、CE值,动态计算当前尖角形箭头需要绘制的像素位置,对起点和终点进行尖角形箭头腐蚀操作,并完成绘制:Step 4: Get the initial world coordinate system line width and map scale scaling factor in the CPU, and pass them to the GPU according to the M value, S value, CB value, and CE value in the state protocol. Then, parse the U value, V value, D value, M value, S value, CB value, and CE value in the state protocol in the GPU shader, dynamically calculate the pixel position where the current sharp arrow needs to be drawn, perform the sharp arrow erosion operation on the starting point and the end point, and complete the drawing:A.将起点处的膨胀正方形的四个点U值统一加上1.0,从而形成一个0.0到-1.0的区间;将终点处的膨胀正方形的四个点U值统一加上10.0,从而形成一个0.0到-1.0的区间;A. Add 1.0 to the U value of the four points of the expanded square at the starting point, thus forming an interval from 0.0 to -1.0; add 10.0 to the U value of the four points of the expanded square at the end point, thus forming an interval from 0.0 to -1.0;B.根据V值将膨胀正方形分为上下两个部分,如果V≤0.5则处于下半部分,如果V>0.5则处于上半部分;B. Divide the expanded square into two parts according to the V value. If V≤0.5, it is in the lower part, and if V>0.5, it is in the upper part.B1.上半部分:按照-0.5的斜率,V>-0.5U则进行腐蚀;B1. Upper part: Corrosion is performed at a slope of -0.5, if V>-0.5U;B2.下半部分:按照0.5的斜率,V<0.5U则进行腐蚀;B2. Lower part: Corrosion is performed at a slope of 0.5, if V<0.5U;根据上述腐蚀操作,完成尖角形箭头的绘制。According to the above erosion operation, the drawing of the pointed arrow is completed.2.根据权利要求1所述的顾及线宽一致性的矢量地图线符号尖角形箭头绘制方法,其特征在于,所述步骤2中,沿线走向的U值根据每个顶点沿着线要素的距离计算获得,其中起点扩张出来的两个顶点U值均为0,终点扩张出来的两个顶点U值均为整条线的长度除以线宽,其他点扩张出来的两个顶点U值均为长度累积值除以线宽。2. According to the method for drawing pointed arrows of vector map line symbols taking into account line width consistency as described in claim 1, it is characterized in that, in the step 2, the U value along the line is calculated based on the distance of each vertex along the line element, wherein the U values of the two vertices expanded from the starting point are both 0, the U values of the two vertices expanded from the end point are both the length of the entire line divided by the line width, and the U values of the two vertices expanded from other points are both the cumulative value of the length divided by the line width.3.根据权利要求1所述的顾及线宽一致性的矢量地图线符号尖角形箭头绘制方法,其特征在于,所述步骤2中,垂直线走向的V值根据每个顶点向两侧扩张的距离计算获得,线要素上的每个点,其扩张出来的两个顶点位于线走向左侧的V值为1,位于右侧的V值为0。3. The method for drawing vector map line symbol pointed arrows taking into account line width consistency according to claim 1 is characterized in that in step 2, the V value of the vertical line direction is calculated based on the distance expanded from each vertex to both sides, and for each point on the line element, the V value of the two vertices expanded from the left side of the line direction is 1, and the V value of the two vertices expanded from the right side is 0.4.根据权利要求1所述的顾及线宽一致性的矢量地图线符号尖角形箭头绘制方法,其特征在于,所述步骤2中,顶点缩放方向的D值是一个二维向量,该二维向量的长度根据扩张顶点与原始点之间的距离计算获得。4. According to the method for drawing pointed arrows of vector map line symbols taking into account line width consistency as described in claim 1, it is characterized in that in the step 2, the D value in the vertex scaling direction is a two-dimensional vector, and the length of the two-dimensional vector is calculated based on the distance between the expanded vertex and the original point.
CN201911365157.3A2019-12-262019-12-26 A method of drawing vector map line symbols with pointed arrows in consideration of line width consistencyActiveCN111145303B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN201911365157.3ACN111145303B (en)2019-12-262019-12-26 A method of drawing vector map line symbols with pointed arrows in consideration of line width consistency

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN201911365157.3ACN111145303B (en)2019-12-262019-12-26 A method of drawing vector map line symbols with pointed arrows in consideration of line width consistency

Publications (2)

Publication NumberPublication Date
CN111145303A CN111145303A (en)2020-05-12
CN111145303Btrue CN111145303B (en)2023-04-25

Family

ID=70520384

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN201911365157.3AActiveCN111145303B (en)2019-12-262019-12-26 A method of drawing vector map line symbols with pointed arrows in consideration of line width consistency

Country Status (1)

CountryLink
CN (1)CN111145303B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN112562036B (en)*2020-12-102023-04-07卡斯柯信号(成都)有限公司Method for drawing configuration system turnout icon by linear polygon

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN101923699B (en)*2009-06-102012-09-26炬力集成电路设计有限公司Method and device for reducing CPU consumption in vector graphics filling process
CN103268626A (en)*2013-04-112013-08-28江苏省在这里数字科技有限公司Map linear symbol drawing method and system based on graphics processing unit (GPU)
CN105513110A (en)*2016-01-112016-04-20南京师范大学GPU-based method for drawing linetype map symbol with gradually-varied width
CN110298780B (en)*2018-03-232022-10-28腾讯科技(深圳)有限公司Map rendering method, map rendering device and computer storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
谈心 ; 佘江峰.二维矢量线符号在三维地形表面的贴合渲染方法.地球信息科学学报.2015,(第012期),*

Also Published As

Publication numberPublication date
CN111145303A (en)2020-05-12

Similar Documents

PublicationPublication DateTitle
US8416244B2 (en)Rendering a text image following a line
US9495767B2 (en)Indexed uniform styles for stroke rendering
CN101751682B (en)Preparation method of universal map
CN105513110A (en)GPU-based method for drawing linetype map symbol with gradually-varied width
CN112100795B (en)Computer aided design drawing comparison method and device
CN112233215A (en)Contour rendering method, apparatus, device and storage medium
WO2013048843A1 (en)Label positioning technique to reduce crawling during zoom activities
CN103606184A (en)Device based on two-dimensional and three-dimensional integrated vector render engine
CN111145303B (en) A method of drawing vector map line symbols with pointed arrows in consideration of line width consistency
CN111145299B (en)Vector map solid line symbol corner drawing method considering line width consistency
CN111127297B (en)Vector map solid line symbol drawing method considering line width consistency
CN111145296B (en) A method of drawing vector map line symbol circular arrows considering the consistency of line width
CN111028352B (en) Drawing method of vector map line symbol open pointed arrow taking into account line width consistency
CN111145302B (en)Vector map square dotted line symbol drawing method considering line width consistency
CN111028353B (en)Vector map line symbol dovetail arrow drawing method considering line width consistency
CN111431953B (en)Data processing method, terminal, server and storage medium
CN111145298B (en) A method for drawing fence dotted line symbols on vector maps considering line width consistency
CN111145297B (en) Drawing Method of Vector Map Line Symbol Diamond Arrow Considering Line Width Consistency
CN111145295B (en)Vector map line symbol half-dovetail arrow drawing method considering line width consistency
CN111028351B (en)Vector map line symbol half-sharp angle arrow drawing method considering line width consistency
CN111080744B (en)Vector map line symbol half-open pointed arrow drawing method considering line width consistency
CN111145301B (en) A method for drawing the end of solid-line symbols on vector maps considering the consistency of line width
CN111127589B (en) A method for drawing circular dotted line symbols on vector maps taking into account the consistency of line width
CN117635412A (en)Super-resolution projection mapping method, system and equipment based on GPU acceleration
CN115953517A (en) Rendering Method of 3D Pipe Network Scene Model in Underground Space

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant

[8]ページ先頭

©2009-2025 Movatter.jp