GENERATION ALGORITHM OF DISCRETE LINE IN MULTI-DIMENSIONAL GRIDS

Discrete Global Grids System (DGGS) is a kind of digital multi-resolution earth reference model, in terms of structure, it is conducive to the geographical spatial big data integration and mining. Vector is one of the important types of spatial data, only by discretization, can it be applied in grids system to make process and analysis. Based on the some constraint conditions, this paper put forward a strict definition of discrete lines, building a mathematic model of the discrete lines by base vectors combination method. Transforming mesh discrete lines issue in n-dimensional grids into the issue of optimal deviated path in n-minus-one dimension using hyperplane, which, therefore realizing dimension reduction process in the expression of mesh discrete lines. On this basis, we designed a simple and efficient algorithm for dimension reduction and generation of the discrete lines. The experimental results show that our algorithm not only can be applied in the two-dimensional rectangular grid, also can be applied in the two-dimensional hexagonal grid and the three-dimensional cubic grid. Meanwhile, when our algorithm is applied in two-dimensional rectangular grid, it can get a discrete line which is more similar to the line in the Euclidean space.


INTRODUCTION
Discrete Global Grid System (DGGS) is a kind of multiresolution hierarchy structure, which can take a particular approach to subdivide infinitely and it takes data manipulation by using code instead of traditional coordinate.Compared with traditional spatial data organization and application pattern, DGGS is more suitable to solve the global large-scale problem.And in terms of structure, DGGS support for efficient processing of multi-resolution data.
Vector data grid expressions are widely used in the spatial topology analysis and grid index, regarded as one of the key issues in the discrete global grid study.Their core is the expression of the points, the lines and the surfaces in the grid.For the points in the grid, their expression is so easy, just the grid unit that their coordinates correspond to.And if we want to express the discrete surfaces, we should also express the corresponding lines firstly.So, we can know that the most important thing in vector data grid expression is the expression of the grid discrete line.Currently, the discrete line generation algorithm has been widely studied, and there have been many efficient algorithms.Among them, the DDA (Digital Differential Analyzer) algorithm, the midpoint Line algorithm and the Bresenham algorithm are several representative algorithms.In addition, Wu and Rokne et al improve the Bresenham algorithm, and raise double-step line generation algorithm.Liu Jing and Jia Yinliang et al consider the correlation between pixels and raise an improved Bresenham algorithm based on pixel row.Now, although the existing discrete line generation algorithm can fit straight line, there is a common problem.That is, there is no concrete description of the generation of discrete lines from a mathematical abstract angle.So, we can can't reveal the essential because lack theoretical support.Pointing to the question, in this paper, we use the method of vector basis linear combination to establish the strict mathematical model of the discrete line, and turn it into the optimal deviation path problem.According to this thought, we design the generation algorithm.Experimental results show that the new algorithm is not only effective but also has certain advantages in the accuracy of expression.

The Constraints Of Grid Discrete Lines
The basic principle of vector data expression in grid is that the expression of a vector in the grid is as close to its shape in the Euclidean space as possible to ensure data characteristics.However, the discrete lines expressed by grid units are very different from the linear segment in the traditional European space.There are many possible paths to connect two grid units within a certain range (as shown in Figure 1).So, if we want to generate a grid line which is the most close to the reality, tighter restrictions are needed.The restrictions in n dimensional space are defined as follows: (1) The length is the shortest(that is, minimum number of units are passed; (2)Calculate the vertical distance of each grid to the line, find the maximum distance and minimize this maximum distance; They are expressed mathematically, in n dimensional space, the discrete grid line ab = a, p 1 , p 2 , … , p N , b , p 1 , p 2 , … , p N is the grid unit that passes in turn.It should meet the following conditions: (1)N should be smallest; (2)The discrete grid that meet condition (1) should make d(p k , 1≤k≤N max ab) is minimal; Under these constraints, we can determine the optimal path for connecting two grid units.

Vector Expression Of The Discrete Line
In order to describe the grid discrete line accurately, this paper use vector to describe multi-dimensional grid discrete line.This approach has the following benefits: (1)We can guarantee that the number of mathematical object parameters described is consistent with the spatial dimension, that is, the discrete grid line can be expressed by n linearly independent vectors.We can describe it by mathematical language: are n linearly independent vectors, called the vector base for the grid discrete line; (2)The expression of the vector base is applied to the orthogonal grid as well as the non-orthogonal grid.So, in this way, the general expression of grid can be carried out and the method has universal applicability; Also, to ensure that each step for generation of discrete grid is equal, we just choose the vector base from the edge adjacent grid unit vector, shown as the red vector in Figure 2.

Determine The Optimal Vector Basis
The choice of vector base is not blind, only the vector group that is best suited for the expression of grid discrete line can be defined as the optimal vector base.Notice that the n dimensions discrete grid space is divided into different spaces by the cone, each cone is composed of n independent vectors from the origin of the same coordinate.So, actually, the cone is the geometric expression of the vector base.But the cone-shaped space that contains the discrete line is not exclusive, the deviation of the grid in the tracing of the discrete line should not exceed the conical space and the smaller the conical space, the smaller the deviation of the grid in the tracking process.Based on this, we can define the vector base which forms a minimum cone as the optimal vector base.Figure 3 is the smallest conical space for different types of two-dimensional grids.For n dimensional discrete grid space, the optimal vector base is composed of n neighbouring linearly independent vectors.Now we can determine the optimal basis for the discrete line.In fact, after determining the optimal vector base, we can design algorithm using the optimal vector base and generate multidimensional discrete grid line directly under the above constraints.But we should know what we study is a multi-dimensional problem, if we follow the discrete line directly in the multi-dimensional discrete space, the complexity of the problem and the difficulty of computing will increase rapidly as the dimensions rise.In this case, it's more advantageous to take a reduce dimension approach to generate discrete lines.
In fact, the mathematical model of the n dimension discrete grid line model and n-1 dimension optimal deviation path model is equivalent, so, we can generate n dimension discrete grid line by dealing with n-1 dimension optimal deviation path question.The basic idea is as follows: Generate a hyperplane that Perpendicular to the vector line ab → , the so-called hyperplane is the mapping subspace of n dimensional space to n-1 dimensional space.We call the vertical projection of the vector base to H as proj H . Let V={proj H (v ′ )|v ′ ∈ V ′ }, V ′ is a collection of the optimal vector base for the grid discrete line.To separate the elements in V from the elements in V ′ , we call V the vector projection base.In addition, we define m v = m v ′ , m v is the sum of the vector projection base, m v ′ is the sum of the vector base.
→ and H is orthogonal, so We define the elements in the set W ′ = (w 1 ′ , w 2 ′ , ⋯ , w N ′ ) consist of arbitrary vector in V ′ .Let w i = proj H (w i ′ ) and define u k as u k = w 1 + w 2 + ⋯ + w k , so P( 0 = u 0 , u 1 , u 2 , ⋯ u N = 0) is a closed path and d (p k , ab → ) = u k .What we're looking for is the optimal path for A, it corresponds to the grid discrete line.At this point, the discrete linear model of n dimension grid space is transformed into an n-1 dimension optimal deviation path model successfully.

Generation Algorithm
According to the basic idea proposed in 2.1, we propose a simple, efficient optimal deviation path generation algorithm, and then we can convert the optimal path to the corresponding space vector to get the ideal discrete grid line.The implementation steps are as follows: (1)Initialization: i = 0, u 0 = 0; (2)Take the smaller vector v from V: (3)When u i = u i 0 and i 0 < i, return the best closed path, otherwise, go to the second step; This algorithm can be represented by flowchart as shown in Figure 4, R n is the set of the optimal vector base that is selected by the input vector line.

Start
Enter the base set in Rn

TEST AND RESULT ANALYSIS
Currently, the more widely used two-dimension discrete grid line generation algorithm is the Bresenham algorithm, the basic principle is to select the grid unit which is most approximating the line in the maximum displacement direction.Because of the limitations of the principle, the Bresenham algorithm fails to track all the grids that the vector line passes through.In this paper, we propose dimension reduction algorithm which can trace all the grid units that the vector line passes through, so the final result of the two algorithms should be different.To validate and compare this difference, we do a comparative experiment firstly.
The data used in the experiment are data on the border of Henan province, a total of 21567 points and the data form is the longitude and latitude coordinates.

The Contract Of Efficiency Between Bresenham Algorithm And Dimension Reduction Algorithm
To get the algorithm run time as accurately as possible, in twodimension, we set the length of the grid edge to 1.So the data of 3872098 two-dimension grid data points can be obtained by using the Bresenham algorithm with 21,567 original data points and 5345314 for dimension reduction algorithm.To compare the efficiency of the two algorithms, we repeat the experiment five times using two different algorithms and took the mean time.The result is shown in

The Contract Of Result Between Bresenham Algorithm And Dimension Reduction Algorithm
To visualize the results of the two algorithms, we convert the generated grid data into a Shapefile file and display it in the Global Mapper software.Firstly, the overall effect of the Henan provincial boundary is basically consistent with the two algorithms, shown as Figure 5.The comparison of the Table 2 shows that the dimension reduction algorithm can indeed track all the grid units which are passed by the vector line.Precisely for this reason, the discrete grid line generated by the dimension reduction algorithm has the following advantages over the result of Bresenham algorithm: (1)The vector line is closer to the central axis of the discrete grid line, this means that the generated discrete grid line is closer to the expression of the vector line in the European space; (2)The continuity of generated discrete grid line is better, all adjacent grid units exist in adjacent edge forms; (3)The display of the corners is more detailed;

The Application Of Dimension Reduction Algorithm
On one hand, because the discrete line is described by vector base, the dimension reduction algorithm can be applied not only to the orthogonal grid but also to the non-orthogonal grid.In other words, the dimension reduction algorithm can be applied to other shapes.In this paper, the discrete line is successfully generated by the dimension reduction algorithm in the hexagon grid.We express the hexagon grid in a flat rectangular coordinate system, to facilitate the definition of coordinates, we set the length of hexagon grid edge is √3 3 . Table 3 records the coordinates of each node of the vector line.Figure 6 shows the generated vector line in the hexagon grid, red grid is node of discrete grid line.It is known by the generated results that, similar to the effect in the square grid, in the hexagon grid, the dimension reduction algorithm still selects all the grid units that the vector line passes through.

Node
Coordinate Table 3.The coordinates of each node of the vector line Figure 6.The generated vector line in the hexagon grid On the other hand, reduce the dimension is the core of dimension reduction algorithm, it can be extended to multidimension.Take the three-dimension grid for example, still use the Henan data and generate discrete grid line in the Space rectangular coordinate system.Figure 7 shows the overall effect and Figure 8 shows some of the details.From the results, we can know that dimension reduction algorithm can generate the discrete grid line which is homogeneous, continuous and can match the vector line accurately.And it proves the feasibility of dimension reduction algorithm in multi-dimension.

Figure 1 .
Figure 1.Schematic diagram of hexagon grid discrete line

Figure 2 .
Figure 2. Schematic diagram of the direction vector Figure 3. Schematic diagram of the smallest conical space

Figure 4 .
Figure 4. Flow chart of dimension reduction algorithm

Figure 5 .
Figure 5. Schematic diagram of the overall effect of the Henan provincial boundary in the rectangle grid

Figure 7 .
Figure 7. Sketch chart of the overall effect in the cube grid

Table 1 .
Table of efficiency statistics

Table 2 .
Comparison table of the detail effect in the rectangle grid