Duality and Dimensionality Reduction Discrete Line Generation Algorithm for a Triangular Grid

: Vectors are a key type of geospatial data, and their discretization, which involves solving the problem of generating a discrete line, is particularly important. In this study, we propose a method for constructing a discrete line mathematical model for a triangular grid based on a “weak duality” hexagonal grid, to overcome the drawbacks of existing discrete line generation algorithms for a triangular grid. First, a weak duality relationship between triangular and hexagonal grids is explored. Second, an equivalent triangular grid model is established based on the hexagonal grid, using this weak duality relationship. Third, the two-dimensional discrete line model is solved by transforming it into a one-dimensional optimal wandering path model. Finally, we design and implement the dimensionality reduction generation algorithm for a discrete line in a triangular grid. The results of our comparative experiment indicate that the proposed algorithm has a computation speed that is approximately 10 times that of similar existing algorithms; in addition, it has better ﬁtting effectiveness. Our proposed algorithm has broad applications, and it can be used for real-time grid transformation of vector data, discrete global grid system (DGGS), and other similar applications.


Introduction
Vector and raster are two fundamental spatial data models, each having advantages for various applications.The process of discretizing a vector to its corresponding grid cells under certain criteria is referred to as "gridding" or "rasterization", with this facilitating the fusion between vector and raster data.In general, vector data models abstract real-world entities into a combination of geometric elements, such as points, lines, and polygons [1].The discretization of geometric elements therefore forms the basis of vector data discretization.For discretization of line and polygon elements, the grid path or grid boundary of the line or polygon must first be determined.Thus, the core problem of discretization is the generation of a discrete line [2,3].
In the fields of computer graphics and geographical information systems, various efficient discrete line generation algorithms have been developed.Typical examples include the digital differential analyzer (DDA) algorithm [4], the midpoint line algorithm [5], and the Bresenham algorithm [6].Furthermore, based on the latter, Wu and Rokne proposed a double-step incremental generation algorithm [7], Jia proposed a six-step algorithm for line drawing [8], and Huang and Zhang proposed a self-adaptive step straight-line algorithm [9].These algorithms were primarily intended for rectangular (quadrangular) grids; however, triangular and hexagonal grids are also used in many applications.It should be noted that although Vince [10] developed a mathematical model for discrete lines based on a multidimensional grid system and designed a corresponding algorithm, this model is applicable only to grid systems obtained by moving the centrosymmetric cell, such as a square, hexagon, or cube; thus, this algorithm is not suitable for a triangular grid, the cells of which are noncentrosymmetric.The triangular grid has been applied to discrete global grid system (DGGS).Representative achievements include Sphere Quad Tree [11] and Quaternary Triangular Mesh (QTM) [12], which are mainly used in spatial data indexing [13] and map generalization models [14].Both hexagonal and diamond grids can be formed by triangular grid polymerization.During the visualization process, some typical 3D programming interfaces, such as OpenGL, provide the function to directly handle triangular grids after triangulation and striping of complex objects [15]; triangular grids are therefore useful.However, they are not uniformly adjacent; (in the case of grid cells, adjacency may be at edges, vertices, or both-if there is only edge adjacency, the grid is uniformly adjacent, otherwise it is non-uniformly adjacent).Grid cells also have different orientations (including upper and lower triangles), and the geometric structure of triangular grids is therefore quite complex, posing challenges for discrete line generation.There is also a dearth of related research.Freeman proposed a vertex-to-vertex discrete line generation algorithm that selects grid cells based on the distance between the vertex and vector line [16]; consequently, some cells of the discrete line deviate from the vector line.Nagy generated a discrete line using neighborhood sequences in a triangular grid [17]; the constraining conditions, including adjacent relationship of grid cells and length of the shortest path, are not sufficient to guarantee the uniqueness of a path.Sarkar proposed the shortest path search algorithm along the boundary of the triangular grid cell [18]; however, this algorithm ignores the relationship between the cell center and the vector line.Zhang proposed the full-path algorithm, in which, according to the geometric relationship between the vector line and grid cell, all grid cells crossed by the vector line are selected one by one [2]; the discrete line generated by this algorithm is ideal, but the process is complex, and computation speeds are slow.Dutt discussed the case in which a straight line crosses a vertex of the triangular grid cell, and based on this case, proposed a discrete line generation algorithm for a triangular grid [19]; however, the entire process needs to be conducted in a triaxial coordinate system, with the consequence that computation speeds are slow.In summary, for the generation of a discrete line in a triangular grid, there is currently no algorithm that has both satisfactory outcomes and reasonable computation speeds.We therefore propose a new algorithm in order to advance this research field.
Compared with a triangular grid, the geometric structure of a hexagonal grid is ideal, making it easy to establish the discrete line model.Based on the structural characteristics of triangular and hexagonal grids, we therefore define a new positional relationship between the two grid systems henceforth referred to as "weak duality", which ensures maximum overlap between the centers of hexagonal and triangular grids.Based on this weak duality relationship between grid systems, we establish a mathematical model for triangular grid discrete line generation, using the hexagonal discrete line model.In addition, we solve the model using the dimensionality reduction method to theoretically simplify the problem.

Definition of Duality and Weak Duality
Generally speaking, a duality in mathematics translates concepts, theorems, or mathematical structures into other concepts, theorems, or structures, in a one-to-one fashion [20].For example, the duality of the grid refers to the unique positional relationship between two different grid systems.For a regular grid, the corresponding duality grid can be obtained by connecting the centers of adjacent cells and considering them as vertices [21].A duality relationship exists between a triangular grid and a hexagonal grid.Let the side length of the triangular grid cell be l t ; then, the side length of the hexagonal grid cell having a duality relationship with it is l h = 1 √ 3 l t , and their sides are perpendicular to each other, as shown in Figure 1.The center of the grid cell is typically used as a reference point for calculation and location, instead of the entire grid cell [22].To simplify the process of grid transformation, the centers of the triangular and hexagonal grid cells should therefore be as coincident as possible.It is evident that the duality relationship shown in Figure 1 cannot meet this requirement.However, by adjusting the side length of the hexagonal grid cell to , and letting it be parallel to the side of the triangular grid cell, the center of a hexagonal grid cell not centered at the vertex of the triangular grid coincides with that of the triangular grid cell, as shown in Figure 2. In this study, this relationship is referred to as weak duality, and it can ensure that the centers of triangular and hexagonal grid cells coincide, facilitating transformation of the grid system.

Discrete Line Model of a Triangular Grid
Because of the non-uniform adjacency (the grid cells of the triangular grid have both edge and vertex adjacency) and dissimilar directions of cells in a triangular grid, it is difficult to establish a discrete line model for the grid.In contrast, it is easier to establish a discrete line model in a hexagonal grid.Based on the weak duality relationship between triangular and hexagonal grids, we can simplify the discrete line model in a triangular grid by transforming the discrete line model of a hexagonal grid into that of a triangular grid.The center of the grid cell is typically used as a reference point for calculation and location, instead of the entire grid cell [22].To simplify the process of grid transformation, the centers of the triangular and hexagonal grid cells should therefore be as coincident as possible.It is evident that the duality relationship shown in Figure 1 cannot meet this requirement.However, by adjusting the side length of the hexagonal grid cell to l h = 1 3 l t , and letting it be parallel to the side of the triangular grid cell, the center of a hexagonal grid cell not centered at the vertex of the triangular grid coincides with that of the triangular grid cell, as shown in Figure 2. In this study, this relationship is referred to as weak duality, and it can ensure that the centers of triangular and hexagonal grid cells coincide, facilitating transformation of the grid system.The center of the grid cell is typically used as a reference point for calculation and location, instead of the entire grid cell [22].To simplify the process of grid transformation, the centers of the triangular and hexagonal grid cells should therefore be as coincident as possible.It is evident that the duality relationship shown in Figure 1 cannot meet this requirement.However, by adjusting the side length of the hexagonal grid cell to , and letting it be parallel to the side of the triangular grid cell, the center of a hexagonal grid cell not centered at the vertex of the triangular grid coincides with that of the triangular grid cell, as shown in Figure 2. In this study, this relationship is referred to as weak duality, and it can ensure that the centers of triangular and hexagonal grid cells coincide, facilitating transformation of the grid system.

Discrete Line Model of a Triangular Grid
Because of the non-uniform adjacency (the grid cells of the triangular grid have both edge and vertex adjacency) and dissimilar directions of cells in a triangular grid, it is difficult to establish a discrete line model for the grid.In contrast, it is easier to establish a discrete line model in a hexagonal grid.Based on the weak duality relationship between triangular and hexagonal grids, we can simplify the discrete line model in a triangular grid by transforming the discrete line model of a hexagonal grid into that of a triangular grid.

Discrete Line Model of a Triangular Grid
Because of the non-uniform adjacency (the grid cells of the triangular grid have both edge and vertex adjacency) and dissimilar directions of cells in a triangular grid, it is difficult to establish a discrete line model for the grid.In contrast, it is easier to establish a discrete line model in a hexagonal grid.Based on the weak duality relationship between triangular and hexagonal grids, we can simplify the discrete line model in a triangular grid by transforming the discrete line model of a hexagonal grid into that of a triangular grid.

Discrete Line Model of a Hexagonal Grid
The corresponding discrete line of vector line ab is a grid path that fits the vector line accurately.In a hexagonal grid, we consider a set of vectors from the center of a cell to the center of its adjacent cells as direction vectors, shown in Figure 3. Two direction vectors that are not on the same line are linearly independent, and the discrete line from the starting cell to the ending cell can be represented by the ordered sequence of any two linearly-independent direction vectors.In practice, the two direction vectors that have the smallest angle with the vector line are selected to generate the discrete line; these two direction vectors are referred to as optimal direction vectors and are denoted by , where m v is a unique positive integer.

Discrete Line Model of a Hexagonal Grid
The corresponding discrete line of vector line ab is a grid path that fits the vector line accurately.In a hexagonal grid, we consider a set of vectors from the center of a cell to the center of its adjacent cells as direction vectors, shown in Figure 3. Two direction vectors that are not on the same line are linearly independent, and the discrete line from the starting cell to the ending cell can be represented by the ordered sequence of any two linearly-independent direction vectors.In practice, the two direction vectors that have the smallest angle with the vector line are selected to generate the discrete line; these two direction vectors are referred to as optimal direction vectors and are denoted by , where v m  is a unique positive integer.(w , w , , w )  be any ordered multiset of elements from V  ; i.e., w k  can be any element of V  .Then, the hexagonal grid cells that form the discrete line can be expressed as , while the corresponding discrete line can be denoted as We cannot determine the unique discrete line based only on the starting and ending cells; the following constraints are therefore imposed [10]: 1.There should be a minimum number of discrete line cells; 2. Of all discrete lines that satisfy (1), the selected discrete line should minimize The discrete line satisfying the constraints is unique and has the highest fitting accuracy among all discrete lines satisfying (1), as shown in Figure 4. Fitting accuracy can be described by the vertical distance between the center of the discrete line cell and the vector line.In general, the shorter the vertical distance, the higher the fitting accuracy.Let W = (w 1 , w 2 , • • • , w N ) be any ordered multiset of elements from V ; i.e., w k can be any element of V .Then, the hexagonal grid cells that form the discrete line can be expressed as We cannot determine the unique discrete line based only on the starting and ending cells; the following constraints are therefore imposed [10]: 1.
There should be a minimum number of discrete line cells; 2.
Of all discrete lines that satisfy (1), the selected discrete line should minimize max where d(u k , ab) is the vertical distance from u k to ab.
The discrete line satisfying the constraints is unique and has the highest fitting accuracy among all discrete lines satisfying (1), as shown in Figure 4. Fitting accuracy can be described by the vertical distance between the center of the discrete line cell and the vector line.In general, the shorter the vertical distance, the higher the fitting accuracy.

Discrete Line Model of a Weak Duality Triangular Grid
The hexagonal grid shown in Figure 4 describes the corresponding weak duality triangular grid; there is a conversion relationship between triangular and hexagonal grids.Furthermore, as shown in Figure 5, based on the weak duality relationship, the grid cells of the hexagonal discrete line are divided into two types; cells belonging to the first type are those with centers coinciding with triangular centers, shown by blue dots, while cells belonging to the second type are those with centers coinciding with triangular vertices, indicated by green dots.Let u k represent the discrete line cells of the triangular grid, and let u k  represent those of the hexagonal grid.For the first cell type, u u k k   ; however, for the second cell type, further analysis is required.As shown in Figure 6, the discrete line cell of the hexagonal grid u A  , which belongs to the second cell type, has two adjacent cells, the centers of which correspond to the triangular cells, with these having the same direction.Let u B  be the previous cell of u A  , and let vectors 0 v and 1 v be the optimal direction vectors of line ab , and let u C be the corresponding triangular cell of u A  .
We can obtain the center of u C by moving the center of u B  along the vector 1 v .

Discrete Line Model of a Weak Duality Triangular Grid
The hexagonal grid shown in Figure 4 describes the corresponding weak duality triangular grid; there is a conversion relationship between triangular and hexagonal grids.Furthermore, as shown in Figure 5, based on the weak duality relationship, the grid cells of the hexagonal discrete line are divided into two types; cells belonging to the first type are those with centers coinciding with triangular centers, shown by blue dots, while cells belonging to the second type are those with centers coinciding with triangular vertices, indicated by green dots.Let u k represent the discrete line cells of the triangular grid, and let u k represent those of the hexagonal grid.For the first cell type, u k = u k ; however, for the second cell type, further analysis is required.

Discrete Line Model of a Weak Duality Triangular Grid
The hexagonal grid shown in Figure 4 describes the corresponding weak duality triangular grid; there is a conversion relationship between triangular and hexagonal grids.Furthermore, as shown in Figure 5  As shown in Figure 6, the discrete line cell of the hexagonal grid u A  , which belongs to the second cell type, has two adjacent cells, the centers of which correspond to the triangular cells, with these having the same direction.Let u B  be the previous cell of u A  , and let vectors 0 v and 1 v be the optimal direction vectors of line ab , and let u C be the corresponding triangular cell of u A  .
We can obtain the center of u C by moving the center of u B  along the vector 1 v .As shown in Figure 6, the discrete line cell of the hexagonal grid u A , which belongs to the second cell type, has two adjacent cells, the centers of which correspond to the triangular cells, with these having the same direction.Let u B be the previous cell of u A , and let vectors v 0 and v 1 be the optimal direction vectors of line ab, and let u C be the corresponding triangular cell of u A .We can obtain the center of u C by moving the center of u B along the vector v 1 .
In contrast, as shown in Figure 7, the triangular cells to which the centers of u B and u C correspond have different directions.Cells u D , u E , u F , and u G might correspond to u A .By moving the centers of u A and u B along the vector v 0 , we can obtain the centers of u D and u E .In a similar manner, the centers of u F and u G can be obtained by moving the centers of u A and u C along the vector −v 0 .Based on the positional relationship between the centers of u A , u D , u E , and line ab, the corresponding triangular cells of u A can be determined.If the centers of u A , u D , u E are on different sides of the line, the corresponding triangular cells of u A are u D and u E ; otherwise, the corresponding cells are u F and u G .Using the abovementioned corresponding relationships based on the discrete line model of a hexagonal grid and some simple manipulations, we can obtain the triangular grid discrete line of vector line ab , thus achieving the transformation between these two types of discrete line model.

Dimensionality Reduction Algorithm of the Discrete Line Model
As discussed in the previous section, the premise of obtaining the triangular grid discrete line is solving the corresponding hexagonal grid discrete line that has a weak duality relationship with the triangular grid.Given line ab in a two-dimensional hexagonal grid, we can solve the discrete line using the optimal direction vectors and constraining conditions.However, it is necessary to repeatedly calculate and compare the distance from the center of the cell to the line; this reduces the computation speed of this method.By projecting the optimal direction vectors of a hexagonal grid discrete line to the straight line perpendicular to line ab , we can transform the discrete line formed by the ordered arrangement of the optimal direction vectors to a closed path on the one-dimensional straight line, thereby reducing dimension and computational complexity.

One-Dimensional Equivalent Form of the Hexagonal Grid Discrete Line Model
For a one-dimensional line, the two opposite vectors that originate from the origin are denoted  Using the abovementioned corresponding relationships based on the discrete line model of a hexagonal grid and some simple manipulations, we can obtain the triangular grid discrete line of vector line ab , thus achieving the transformation between these two types of discrete line model.

Dimensionality Reduction Algorithm of the Discrete Line Model
As discussed in the previous section, the premise of obtaining the triangular grid discrete line is solving the corresponding hexagonal grid discrete line that has a weak duality relationship with the triangular grid.Given line ab in a two-dimensional hexagonal grid, we can solve the discrete line using the optimal direction vectors and constraining conditions.However, it is necessary to repeatedly calculate and compare the distance from the center of the cell to the line; this reduces the computation speed of this method.By projecting the optimal direction vectors of a hexagonal grid discrete line to the straight line perpendicular to line ab , we can transform the discrete line formed by the ordered arrangement of the optimal direction vectors to a closed path on the one-dimensional straight line, thereby reducing dimension and computational complexity.

One-Dimensional Equivalent Form of the Hexagonal Grid Discrete Line Model
For a one-dimensional line, the two opposite vectors that originate from the origin are denoted by the set Using the abovementioned corresponding relationships based on the discrete line model of a hexagonal grid and some simple manipulations, we can obtain the triangular grid discrete line of vector line ab, thus achieving the transformation between these two types of discrete line model.

Dimensionality Reduction Algorithm of the Discrete Line Model
As discussed in the previous section, the premise of obtaining the triangular grid discrete line is solving the corresponding hexagonal grid discrete line that has a weak duality relationship with the triangular grid.Given line ab in a two-dimensional hexagonal grid, we can solve the discrete line using the optimal direction vectors and constraining conditions.However, it is necessary to repeatedly calculate and compare the distance from the center of the cell to the line; this reduces the computation speed of this method.By projecting the optimal direction vectors of a hexagonal grid discrete line to the straight line perpendicular to line ab, we can transform the discrete line formed by the ordered arrangement of the optimal direction vectors to a closed path on the one-dimensional straight line, thereby reducing dimension and computational complexity.

One-Dimensional Equivalent Form of the Hexagonal Grid Discrete Line Model
For a one-dimensional line, the two opposite vectors that originate from the origin are denoted by the set V = {v 0 , v 1 }.If there is a positive integer set {m v |v ∈ V} that makes ∑ v∈V m v v = 0, then V is considered the basic set in the one-dimensional space.Let W = (w 1 , w 2 , • • • , w N ) be any ordered multiset of elements from set V, and ûk = w 1 + w 2 + w 3 + • • • + w k .We can obtain a path on a one-dimensional line by connecting 0 = û1 , û2 , û3 , . . ., ûN .In addition, if ûN = 0, the path P : (0 = û1 , û2 , û3 , . . ., ûN = 0) is a closed path.Let w(P) = max 1≤k≤N | ûk | (| ûk | is the distance from ûk to origin) be the farthest distance that path P wanders from the origin.Then, w(V) = minw(P) is the optimal wandering distance for set V, and the corresponding closed path is referred to as the optimal wandering path [10].
As described in Section 3.1, the ideal discrete line should satisfy the previously mentioned constraints.After determining the optimal direction vectors, the number of discrete line cells will be minimal.Furthermore, in order to obtain the vertical distance d(u k , ab), we consider a straight line H that goes through the starting point a and is perpendicular to line ab; proj H is the vertical projection operator on H.Because line ab is perpendicular to H, the projections of a and b coincide, and the vertical projections of the optimal direction vector set V = v 0 , v 1 onto H form the basic set ( ) min ( ) w V w P  is the optimal wandering distance for set V , and the corresponding closed path is referred to as the optimal wandering path [10].
As described in Section 3.1, the ideal discrete line should satisfy the previously mentioned constraints.After determining the optimal direction vectors, the number of discrete line cells will be minimal.Furthermore, in order to obtain the vertical distance (u , ab) , we consider a straight line H that goes through the starting point a and is perpendicular to line ab ; proj H is the vertical projection operator on H .Because line ab is perpendicular to H , the projections of a and b coincide, and the vertical projections of the optimal direction vector set , as shown in Figure 8.Therefore, the discrete line of the two-dimensional hexagonal grid

Algorithm for Solving the Discrete Line of a Triangular Grid
Based on the above analysis, it is clear that the key to determining the optimal wandering path is to minimize To achieve this objective, we adopt the greedy algorithm, i.e., the selected vector in each step ensures that the current path is closest to the origin.The greedy algorithm is heuristic, as a result of which the solutions obtained by this algorithm may only be locally optimal; however, in this study, the solution obtained by the greedy algorithm is globally optimal, as per the following deduction: Consider that is the optimal wandering path obtained by the greedy algorithm and 1 2 3 ˆˆˆ{ t , t , t , , t } N  is any non-optimal wandering path.According to the greedy algorithm, each node in the optimal wandering path is closest to the origin, so

Algorithm for Solving the Discrete Line of a Triangular Grid
Based on the above analysis, it is clear that the key to determining the optimal wandering path is to minimize w(P) = max 1≤k≤N | ûk |.To achieve this objective, we adopt the greedy algorithm, i.e., the selected vector in each step ensures that the current path is closest to the origin.The greedy algorithm is heuristic, as a result of which the solutions obtained by this algorithm may only be locally optimal; however, in this study, the solution obtained by the greedy algorithm is globally optimal, as per the following deduction: Consider that { û1 , û2 , û3 , . . . ,ûN } is the optimal wandering path obtained by the greedy algorithm and { t1 , t2 , t3 , . . . ,tN } is any non-optimal wandering path.According to the greedy algorithm, each node in the optimal wandering path is closest to the origin, so to the greedy algorithm, we can obtain the optimal wandering path, where w(P) = max 1≤k≤N | ûk | must be the smallest of all paths.In other words, the optimal wandering path obtained by the greedy algorithm in our study is globally optimal.
The optimal direction vector set V corresponds to the basic set V; by using the greedy algorithm to find the element of basic set V and the corresponding element of set V in each step, we can therefore obtain the ideal discrete line of the weak duality hexagonal grid.Finally, based on the conversion relationship between the two discrete line models, described in Section 3.2, we obtain the discrete line of the triangular grid.The flowchart for this algorithm is shown in Figure 9.
the conversion relationship between the two discrete line models, described in Section 3.2, we obtain the discrete line of the triangular grid.The flowchart for this algorithm is shown in Figure 9.
The above algorithm successfully obtains the one-dimensional optimal wandering path, the two-dimensional discrete line of the weak duality hexagonal grid, and the two-dimensional discrete line of the triangular grid.Consequently, the proposed method gradually simplifies the problem of obtaining a triangular grid discrete line, thereby considerably improving operational efficiency.

Experiments and Analysis
To verify the effectiveness of our proposed duality and dimensionality reduction discrete line generation algorithm, we compared it with the Freeman [16] and full-path [2] algorithms.In our study, all three algorithms were implemented in C++.Furthermore, except for the different core steps, all operations were kept the same to ensure fair and objective results.Each program was compiled into the Release version and executed on a SAMSUNG 450R5U laptop (Hardware configuration: Intel Core i5-3230M CPU@2.60 GHz, 8 GB RAM; Operating System: Windows 7 × 64 Ultimate version; Development Tools: Visual Studio 2012).The data for the experiment were obtained from the 1:250,000 basic geographic information database of the State Bureau of Surveying and Mapping; these included the vector data of 34 provinces (municipalities directly under the central government and autonomous regions) in China, with a total of 917,264 coordinate points.The above algorithm successfully obtains the one-dimensional optimal wandering path, the two-dimensional discrete line of the weak duality hexagonal grid, and the two-dimensional discrete line of the triangular grid.Consequently, the proposed method gradually simplifies the problem of obtaining a triangular grid discrete line, thereby considerably improving operational efficiency.

Experiments and Analysis
To verify the effectiveness of our proposed duality and dimensionality reduction discrete line generation algorithm, we compared it with the Freeman [16] and full-path [2] algorithms.In our study, all three algorithms were implemented in C++.Furthermore, except for the different core steps, all operations were kept the same to ensure fair and objective results.Each program was compiled into the Release version and executed on a SAMSUNG 450R5U laptop (Hardware configuration: Intel Core i5-3230M CPU@2.60 GHz, 8 GB RAM; Operating System: Windows 7 × 64 Ultimate version; Development Tools: Visual Studio 2012).The data for the experiment were obtained from the 1:250,000 basic geographic information database of the State Bureau of Surveying and Mapping; these included the vector data of 34 provinces (municipalities directly under the central government and autonomous regions) in China, with a total of 917,264 coordinate points.Each provincial boundary was regarded as a closed polygon, and it was processed by all three algorithms.
The fitting degree between the generated discrete line and the actual vector data is an important criterion for evaluating the effectiveness of the algorithm.In practice, the closer the discrete line that is generated by the algorithm is to vector data, the higher the fitting accuracy.In this study, the average vertical distance between the center of the discrete line grid cell and the actual vector line, i.e., the ratio of the sum of the vertical distance of all discrete line cells to the total number of discrete line cells, was taken as a quantitative indicator to evaluate fitting accuracy between the discrete line and actual vector data, denoted as average distance (AVD), unit: meter (m).Generally, the smaller the AVD value, the higher the fitting accuracy of the discrete line.
When the side length of the grid cell was too large, the generated discrete line only consists of a small number of grid cells.In this case, the description of the vector boundary is very approximate and it is of no practical significance for discussing the fitting relationship between the discrete line and vector data.Therefore, in order to clearly compare the overall effectiveness and fitting accuracy of the proposed algorithm and the Freeman algorithm, we set the side length of the grid cell to 3 km and we selected Beijing for provision of test data, allowing for fewer coordinate points (3661 points).The two algorithms were used to generate discrete lines, the results of which are shown in Figure 10.According to the calculations, the AVD values of the proposed algorithm and the Freeman algorithm were 522.829 m and 1102.95m, respectively, indicating higher accuracy of the former.The discrete lines generated by the proposed algorithm are also more continuous and smoother.Compared with the proposed algorithm, the Freeman algorithm selects discrete line grid cells based on the vertical distance between vertex and line, leading to large deviations and poor continuity and smoothness.
(m).Generally, the smaller the AVD value, the higher the fitting accuracy of the discrete line.
When the side length of the grid cell was too large, the generated discrete line only consists of a small number of grid cells.In this case, the description of the vector boundary is very approximate and it is of no practical significance for discussing the fitting relationship between the discrete line and vector data.Therefore, in order to clearly compare the overall effectiveness and fitting accuracy of the proposed algorithm and the Freeman algorithm, we set the side length of the grid cell to 3 km and we selected Beijing for provision of test data, allowing for fewer coordinate points (3661 points).The two algorithms were used to generate discrete lines, the results of which are shown in Figure 10.According to the calculations, the AVD values of the proposed algorithm and the Freeman algorithm were 522.829 m and 1102.95m, respectively, indicating higher accuracy of the former.The discrete lines generated by the proposed algorithm are also more continuous and smoother.Compared with the proposed algorithm, the Freeman algorithm selects discrete line grid cells based on the vertical distance between vertex and line, leading to large deviations and poor continuity and smoothness.
(A) (B) As shown in Table 1, with improved grid resolution, the AVD values of both the Freeman algorithm and the proposed algorithm decrease with a reduction in grid cell side length.When the side lengths of grid cells are equal, the AVD value of the proposed algorithm is lower than that of the Freeman algorithm.This means that higher grid resolution leads to more accurate description of vector data by the discrete line, with better effectiveness using the proposed algorithm.It should be noted that no matter how high the grid resolution, even when the side length of the grid cell is reduced to 3 m, there are still deviations between the discrete line and the actual vector data, as shown in Figure 11.This is because existing discrete line generation algorithms, including the Freeman algorithm, and our proposed algorithm, all use the center or vertex of a grid cell as the reference point to generate the discrete line.However, in practice, the coordinate point of a vector is rarely at the center or vertex of the grid cell.This results in deviations between the discrete line As shown in Table 1, with improved grid resolution, the AVD values of both the Freeman algorithm and the proposed algorithm decrease with a reduction in grid cell side length.When the side lengths of grid cells are equal, the AVD value of the proposed algorithm is lower than that of the Freeman algorithm.This means that higher grid resolution leads to more accurate description of vector data by the discrete line, with better effectiveness using the proposed algorithm.It should be noted that no matter how high the grid resolution, even when the side length of the grid cell is reduced to 3 m, there are still deviations between the discrete line and the actual vector data, as shown in Figure 11.This is because existing discrete line generation algorithms, including the Freeman algorithm, and our proposed algorithm, all use the center or vertex of a grid cell as the reference point to generate the discrete line.However, in practice, the coordinate point of a vector is rarely at the center or vertex of the grid cell.This results in deviations between the discrete line generated by the reference point and actual vector data.This deviation is inevitable in the process of discretization, and determining ways to reduce it will be the focus of our further research.

Application of Our Algorithm in DGGS
DGGS is a promising global multiscale data model.Compared with the traditional geospatial data organization mode within a local area, DGGS is more suitable for large-scale applications, and it structurally supports efficient multi-resolution geospatial data processing [22].Although we have thus far only discussed the application of the algorithm in the plane, the relationship between a plane and a spherical surface can be established by the icosahedron and Snyder projection.In this way, our algorithm can be extended to the spherical surface and applied to DGGS.
In the case of a set of spherical vector data, if this is inside a spherical triangle, it can be projected onto the triangular face using the forward projection (transformation from the spherical surface to the icosahedral triangular faces) of the Snyder projection.On the triangular face, the corresponding triangular grid discrete lines can be generated by our algorithm, and the discrete lines can be projected onto the spherical surface by inverse projection (transformation from the icosahedral triangular faces to the spherical surface) of the Snyder projection, thereby generating discrete lines in DGGS.However, spherical vector data is generally located at the junction of spherical triangles and will therefore be split into different spherical triangles.Following the forward projection of the Snyder projection, the triangular face corresponding to each spherical triangle has an independent coordinate system.The spherical vector data in each spherical triangle can only be processed separately, which requires solving the intersection of the spherical vector data and spherical triangle boundaries.Only in this way can the spherical vector data inside each spherical triangle be determined, and can the corresponding discrete lines be generated in DGGS by the means of the Snyder projection and our algorithm.Although we have solved the problem of the intersection of spherical vector data and spherical triangle boundaries, the specific process is more complicated and it is not the focus of this paper; we will elaborate this further in future publications.
Taking actual spherical vector data as an example, its multi-resolution display in DGGS can be achieved using our algorithm.Results are shown in Figure 12.After generating discrete lines, spatial operations such as buffer generation [23] and overlay analysis can be performed, providing a reference for solving practical problems.

Conclusions and Future Directions
Based on the weak duality relationship between triangular and hexagonal grids, as well as the equivalence relationship between the two-dimensional discrete line and one-dimensional optimal wandering path, we successfully performed transformations between the discrete line of a triangular grid, the discrete line of a weak duality hexagonal grid, and the optimal wandering path, thus reducing the complexity of generating a discrete line in a triangular grid.
Compared with existing algorithms, our algorithm can generate the ideal discrete line and has clear advantages in terms of computation speed.In addition, the concepts of duality and dimensionality reduction provide a new way to solve related discretization problems; our proposed method can therefore support further research.

Conclusions and Future Directions
Based on the weak duality relationship between triangular and hexagonal grids, as well as the equivalence relationship between the two-dimensional discrete line and one-dimensional optimal wandering path, we successfully performed transformations between the discrete line of a triangular grid, the discrete line of a weak duality hexagonal grid, and the optimal wandering path, thus reducing the complexity of generating a discrete line in a triangular grid.
Compared with existing algorithms, our algorithm can generate the ideal discrete line and has clear advantages in terms of computation speed.In addition, the concepts of duality and dimensionality reduction provide a new way to solve related discretization problems; our proposed method can therefore support further research.
Our proposed algorithm can be applied to real-time grid transformation of vector data, and it can also be indirectly applied to DGGS by the means of the Snyder projection and icosahedron.Meanwhile, our algorithm is beneficial for interoperation between hexagonal and triangular grids.The idea of duality and dimensionality reduction can be extended to multi-dimensional spaces; therefore, it is of great significance for the study of high-dimensionality problems, suggesting broad application prospects in the future.

Figure 2 .
Figure 2. Weak duality relationship between hexagonal and triangular grids.

Figure 2 .
Figure 2. Weak duality relationship between hexagonal and triangular grids.

Figure 2 .
Figure 2. Weak duality relationship between hexagonal and triangular grids.

Figure 3 .
Figure 3. Direction vectors of a hexagonal grid.

Figure 3 .
Figure 3. Direction vectors of a hexagonal grid.

Figure 4 .
Figure 4. Discrete line in a hexagonal grid.

Figure 5 .
Figure 5. Corresponding relationship between two discrete line models.

Figure 4 .
Figure 4. Discrete line in a hexagonal grid.

Figure 4 .
Figure 4. Discrete line in a hexagonal grid.
, based on the weak duality relationship, the grid cells of the hexagonal discrete line are divided into two types; cells belonging to the first type are those with centers coinciding with triangular centers, shown by blue dots, while cells belonging to the second type are those with centers coinciding with triangular vertices, indicated by green dots.Let u k represent the discrete line cells of the triangular grid, and let u k  represent those of the hexagonal grid.For the first cell type, u u k k  ; however, for the second cell type, further analysis is required.

Figure 5 .
Figure 5. Corresponding relationship between two discrete line models.

Figure 5 .
Figure 5. Corresponding relationship between two discrete line models.

Figure 6 .
Figure 6.The triangles to which the blue dots correspond have the same direction.In contrast, as shown in Figure 7, the triangular cells to which the centers of u B  and u C  correspond have different directions.Cells , u ,u ,u D E F and u G might correspond to u A  .By moving the centers of u A  and u B  along the vector 0 v , we can obtain the centers of u D and u E .In a similar manner, the centers of u F and u G can be obtained by moving the centers of u A  and u C  along the vector

Figure 7 .
Figure 7.The triangles to which the blue dots correspond have different directions.

Figure 6 .
Figure 6.The triangles to which the blue dots correspond have the same direction.

Figure 6 .
Figure 6.The triangles to which the blue dots correspond have the same direction.In contrast, as shown in Figure 7, the triangular cells to which the centers of u B  and u C  correspond have different directions.Cells , u ,u ,u D E F and u G might correspond to u A  .By moving the centers of u A  and u B  along the vector 0 v , we can obtain the centers of u D and u E .In a similar manner, the centers of u F and u G can be obtained by moving the centers of u A  and u C  along the vector

Figure 7 .
Figure 7.The triangles to which the blue dots correspond have different directions.

Figure 7 .
Figure 7.The triangles to which the blue dots correspond have different directions.
) .In this case, ûk = proj H (u k ) and d(u k , ab) = | ûk |, as shown in Figure8.Therefore, the discrete line of the two-dimensional hexagonal grid a = u 1 , u 2 , • • • , u N = b corresponds to the closed path on the one-dimensional straight line P : (0 = û1 , û2 , û3 , . . ., ûN = 0).Hence, solving the ideal discrete line with the shortest max 1≤k≤N d(u k , ab) in two-dimensional space is equivalent to solving the one-dimensional optimal wandering path that minimizes w(P).
dimensional space is equivalent to solving the one-dimensional optimal wandering path that minimizes ( ) w P .

Figure 8 .
Figure 8. Schematic of the projection relationship.

Figure 8 .
Figure 8. Schematic of the projection relationship.

Figure 9 .
Figure 9. Flowchart of the duality and dimensionality reduction algorithm.

Figure 9 .
Figure 9. Flowchart of the duality and dimensionality reduction algorithm.

Figure 10 .
Figure 10.Comparison of the overall effectiveness of the two algorithms (side length of grid cells is approximately 3 km): (A) discrete line of Beijing boundary generated by the proposed algorithm and (B) discrete line of Beijing boundary generated by the Freeman algorithm.

Figure 10 .
Figure 10.Comparison of the overall effectiveness of the two algorithms (side length of grid cells is approximately 3 km): (A) discrete line of Beijing boundary generated by the proposed algorithm and (B) discrete line of Beijing boundary generated by the Freeman algorithm.

Figure 12 .
Figure 12.Multiresolution discretization of spherical vector data.The white arcs are the boundaries of the spherical triangles, and the figures represent the following: (A) the side length of grid cell is approximately 483 km; (B) the side length of grid cell is approximately 242 km; (C) the side length of grid cell is approximately 121 km.

Figure 12 .
Figure 12.Multiresolution discretization of spherical vector data.The white arcs are the boundaries of the spherical triangles, and the figures represent the following: (A) the side length of grid cell is approximately 483 km; (B) the side length of grid cell is approximately 242 km; (C) the side length of grid cell is approximately 121 km.

Table 1 .
Average distance (AVD) statistical table for Freeman and proposed algorithms.