# A Set of Integral Grid-Coding Algebraic Operations Based on GeoSOT-3D

^{1}

^{2}

^{3}

^{4}

^{5}

^{6}

^{*}

## Abstract

**:**

## 1. Introduction

^{n}-tree 3D (GeoSOT-3D) is a standardized, multiscale, latitude and longitude grid data model [6]. It has the advantages of intuitive expression of the latitude and longitude grid, an effective octree index, and efficient calculation using grid codes [20]. This grid model has 2

^{n}grids in each layer (n is the grid layer), and can use integral multiples of “2” to replace the calculations of floating-point numbers based on longitude and latitude (making it convenient for the computer to conduct binary operations) [11,13,14,19]. Therefore, it is necessary to make full use of the advantages of the binary integer of GeoSOT-3D codes, as the computer’s integer operation efficiency is much better than the floating-point operation. In our study, an integral grid-coding algebraic operation framework based on binary bit operations was developed to support large geospatial data analysis. We developed major algorithms.

## 2. Algebraic Operation Framework for GeoSOT-3D

#### 2.1. GeoSOT-3D Grid Model

^{n}-tree (GeoSOT) spherical 2D model.

- (1)
- Octal one-dimensional code. The code is coded with octal values (0, 1, 2, 3, 4, 5, 6, 7) up to 32 digits long. The length of the code identifies the layer of the grid. When writing the code, it starts with G; the codes for degrees, minutes, and seconds are separated by “-”, and the codes below seconds are separated by “.”. The form is Gddddddddd-mmmmmm-ssssss.uuuuuuuuuuu, where d, m, s, and u are octal numbers with values of 0, 1, 2, 3, 4, 5, 6, 7. The code of each layer of grid is based on the previous layer of the grid code, and the Z-order encoding direction is related to the same layer grid where the grid is located. The octal one-dimensional code is mainly used for index establishment and domain name identification.
- (2)
- Binary one-dimensional code (Figure 3a). The code is composed of 96-bit binary values (0,1), and each three-bit code represents an octal value, so the binary one-dimensional code corresponds exactly to the octal one-dimensional code. The binary one-dimensional code is mainly used for calculation, and is generally stored in the form of a structure. It is impossible to use a variable-length code to express the hierarchical layer of the section, such as an octal one-dimensional code. Therefore, the binary one-dimensional code generally needs the addition of a layer code with a length of 5-bit to represent the layer, and the total length of the code is 96 + 5 = 101 bits.
- (3)
- Binary three-dimensional code (Figure 3b). In the 96-bit binary one-dimensional code of GeoSOT-3D grid, every three-bit binary number represents the code of a grid in a layer. These three digits are disassembled and stored separately to form a GeoSOT-3D binary three-dimensional code. The GeoSOT-3D binary three-dimensional code has an obvious geographic meaning, and 32-bit binary values are used to represent altitude, latitude, and longitude. The first bit of the code indicates the interval in which the grid is located.

#### 2.2. Algebraic Operation Framework Design

**Definition**

**1.**

^{32∗3}).

**Definition**

**2.**

**Definition**

**3.**

- Basic operations.

- Vector operations.

- Metric operations.

- Spatial calculation.

- Topological relationship operations.

- Set operations.

## 3. Algebraic Operations

#### 3.1. Basic Operations

#### 3.1.1. Bitwise Operations

- Bitwise andOperator:&
- Bitwise OROperator:|
- Bitwise XOROperator:^
- Inverted by bitOperator~
- Shift leftOperator:<<
- Shift rightOperator:>>

#### 3.1.2. Get the Layer of Layer

_{Layer}is the operation used to obtain the layer of the code. Since the code length is related to the times the Earth model is subdivided, the code length is the code layer. For example, Code

_{Layer}(100101) = 6.

#### 3.1.3. Code Prefix Operation

_{Pre}.

_{Pre}= Code >> (96 − n); (n is the prefix digits)

#### 3.1.4. Code Suffix Operation

_{Last}.

_{Last}= Code << (96 − n); (n is the suffix digits)

#### 3.2. Vector Operation

_{A}and Code

_{B}is the code of the area pointed to by the new vector, as shown in Figure 7.

#### 3.3. Metric Operation

#### 3.3.1. Distance

_{1}(Code

_{Lon}, Code

_{Lat}, Code

_{Hei}) and C

_{2}(Code

_{Lon}, Code

_{Lat}, Code

_{Hei}) in the three-dimensional space of the Earth is as follows:

_{1}and C

_{2}in three dimensions, and satisfy Span1 > Span2 > Span3. The distance calculation method here is close to the Euclidean distance on the GeoSOT-3D grid. It is important to note that when calculating the distance of a small span, the spherical distance can be approximately equal to the Euclidean distance. If users need to calculate an accurate and large-span distance, they need to convert it back to an ellipsoid. We recommend that the grid distance is only used to indicate the approximate range rather than the precise range, for example, calculations such as fast estimation of length.

#### 3.3.2. Projection Area

_{1}~B

_{2}, and the longitude range is L

_{1}~L

_{2}. The formula for calculating the area of any trapezoid on the ellipsoid is as follows:

_{m}= (B

_{1}+ B

_{2})/2.

#### 3.3.3. Orientation

_{1}(CodeE

_{1}, CodeB

_{1}, CodeL

_{1}), C

_{2}(CodeE

_{2}, CodeB

_{2}, CodeL

_{2}), where C

_{1}is the reference grid, C

_{2}is the pointing grid, and the grid spatial orientation relationship is calculated as Figure 9.

#### 3.4. Spatial Calculation

#### 3.4.1. Neighborhood Operation

_{Lon}, Code

_{Lat}, Code

_{Hei}), a displacement combination of its code in the height dimension, longitude dimension, and latitude dimension represents a certain neighborhood grid of the grid. For a certain dimension Code in the binary 3D code, the code displacement can be performed as follows:

- (1)
- Move a grid forward:$$Cod{e}_{New}=Code+1<<(32-Cod{e}_{Layer})$$
- (2)
- Move a grid in the negative direction:$$Cod{e}_{New}=Code-1<<(32-Cod{e}_{Layer})$$

#### 3.4.2. Parent Grid Operation

_{P}is the calculation operation of the parent grid code; the calculation input is the grid code; the output is the parent grid code of the grid.

#### 3.4.3. Child Grid Operation

_{S}is the calculation operation of the parent grid code; the calculation input is the grid code; the output is the parent grid code of the grid.

#### 3.5. Topological Relationship Calculation

^{0}as the grids with a distance of 1 in the Voronoi diagram (Figure 11).

_{A}and C

_{B}are the binary codes of grid A and B on dimension D, respectively, and the code length is L

_{A}, L

_{B}. The calculation process of the topological relationship between grid A and grid B in dimension D is as follows.

_{A}= L

_{B}), it is judged whether C

_{A}= C

_{B}, meaning that the topological relationship R

_{D}of grid A and B in dimension D is equal; otherwise, the real grid span between L

_{A}and L

_{B}is calculated. If the span is 1, then R

_{D}is adjacent; if the span is larger than 1, then R

_{D}is disjointed.

_{A}> L

_{B}, and the prefix C

_{A}′, whose C

_{A}length is L

_{B}, is taken. If C

_{A}′ = C

_{B}, then B contains A; if C

_{A}′ > C

_{B}, L

_{A}-L

_{B}is added after C

_{B}, and then the topological relationship is calculated according to the same-layer code; if C

_{A}′ < C

_{B}, L

_{A}-L

_{B}0s is added after C

_{B}, and then the topological relationship is calculated according to the same-layer code. According to the proposed method, the topological relations R

_{E}, R

_{B}, and R

_{L}of grid A and grid B in three dimensions can eventually be calculated.

#### 3.6. Set Operations

## 4. Experimental Results

#### 4.1. Experimental Platform and Experiment Design

#### 4.2. Comparison of Vector Operation Efficiency

#### 4.3. Comparison of Metric Operation Efficiency

#### 4.4. Comparison of Topological Operation Efficiency

- (1)
- For the overlay calculation of layers containing a single area object, the algebraic operation’s efficiency is slightly higher than that of the Weiler–Atherton algorithm. Under the experimental conditions in this article, the algebraic operation’s efficiency is increased by about 1.32 times. For the overlapping calculation of two surface objects, the most time-consuming part of the overlay algorithm lies in judgment of the nesting relationship between the two grid sets. This operation is the most basic kind of bit operation. It is related to the number of grids covered by each area object. In comparison, the Weiler–Atherton algorithm’s largest time consumption lies in the judgment of the intersection between two objects. The number of judgments is related to the number of line segments expressing the two surface objects: the number of intersection points.
- (2)
- For the overlay calculation of layers containing multiple area objects, the algebraic operation ‘s efficiency is much higher than that of the Weiler–Atherton algorithm. Under the experimental conditions of this article, the efficiency of the algebraic operation is improved by about 6.44 times. For the overlay calculation between two area object sets, the time consumption of the algebraic operation is related to the size of the overall coverage area of the grid set and the data accuracy. It is associated with the total number of associated grids. It has a weak correlation with the number of objects involved in the calculation. However, the time consumed by the Weiler–Atherton algorithm is related to the number of objects in the reference calculation. The more objects there are, the more intersection points there are that express the spatial information of the objects, and the more times the intersection relationship is judged and the longer this process takes.

#### 4.5. Analysis Efficiency of Algebraic Operation

## 5. Conclusions

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Conflicts of Interest

## Appendix A

void rot (int n, int* x, int* y, int rx, int ry){ |

if (ry == 0){ |

if (rx == 1){ |

*x = n − 1 − *x; |

*y = n − 1 − *y; |

} |

int t = *x; |

*x = *y; |

*y = t; |

} |

} |

void d2xy (int n, int d, int* x, int* y){ |

int rx, ry, s, t = d; |

*x = *y = 0; |

for (s = 1; s < n; s *= 2){ |

rx = 1 & (t / 2); |

ry = 1 & (t ^ rx); |

rot(s, x, y, rx, ry); |

*x += s * rx; |

*y += s * ry; |

t /= 4; |

} |

} |

unsigned int moveR(int n, unsigned code) { |

if (code % 2 == 0) |

return (code + 1); |

n -= 2; |

for (int i = 4; i < n; i = i * 4) { |

if ((code & i) == 0) |

return code & n|i; |

n −= i; |

} |

return 0; |

} |

Function 2: encode: |

Input: longitude, Latitude, Height, Layer Output: GeoSOT-3D Code $\begin{array}{l}\hspace{1em}1:\mathrm{struct}Code\{\\ \hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}\mathrm{unsigned}\mathrm{int}\mathrm{degree}:10;\\ \hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}\mathrm{unsigned}\mathrm{int}\mathrm{minute}:6;\\ \hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}\mathrm{unsigned}\mathrm{int}\mathrm{second}:16;\\ \hspace{1em}\hspace{1em}\};\\ \hspace{1em}2:Cod{e}_{Lon}\leftarrow Longitude\left(degree,minute,second\right)\\ \hspace{1em}3:Cod{e}_{Lat}\leftarrow Latitude\left(degree,minute,second\right)\\ \hspace{1em}4:Cod{e}_{Hei}\leftarrow Height\\ \hspace{1em}5:Cod{e}_{i}(32-layer)(32-layer)\\ \hspace{1em}6:forj=0tolayer\\ \hspace{1em}7:\hspace{1em}\hspace{1em}GeoSOT-3DCode\leftarrow Cod{e}_{i}[j]\\ \hspace{1em}8:endfor\end{array}$ |

Function 3: decode: |

Input: GeoSOT-3D Code Output: longitude, Latitude, Height, Layer $\begin{array}{l}1:[Cod{e}_{lon},Cod{e}_{Lat},Cod{e}_{Hei}]\leftarrow GeoSOTCode\\ 2:Latitude\left(degree,minute,second\right)\leftarrow Cod{e}_{Lat}\\ 3:Longitude\left(degree,minute,second\right)\leftarrow Cod{e}_{Lon}\\ 4:Height\leftarrow Cod{e}_{Hei}\end{array}$ |

Function 4: vector + |

Input: GeoSOT-3D Code1, GeoSOT-3D Code2 Output: GeoSOT-3D Code $\begin{array}{l}//\mathrm{two}\mathrm{binary}{\mathrm{numbers}}^{\prime}\mathrm{bits}\mathrm{are}\mathrm{equal}\mathrm{to}\mathrm{Code}\\ 1:GeoSOT-3DCode=(Cod{e}_{1}|0b101010...10+Cod{e}_{2})0b010101...01\end{array}$ |

## References

- Chen, S. Geo-spatial/temporal Analysis in Geo-processing. J. Remote Sens.
**1997**, 161–171. [Google Scholar] [CrossRef] - Song, J.C.; Zhao, C.L.; Zhong, S.P.; Nielsen, T.A.S.; Prishchepov, A.V. Mapping spatio-temporal patterns and detecting the factors of traffic congestion with multi-source data fusion and mining techniques. Comput. Environ. Urban Syst.
**2019**, 77. [Google Scholar] [CrossRef] - Xiong, X.; Qiao, S.J.; Li, Y.Y.; Han, N.; Yuan, G.; Zhang, Y.Q. A point-of-interest suggestion algorithm in Multi-source geo-social networks. Eng. Appl. Artif. Intell.
**2020**, 88. [Google Scholar] [CrossRef] - Lin, Y.; Wang, H.; Zhang, S.; Li, J.; Gao, H. Efficient quality-driven source selection from massive data sources. J. Syst. Softw.
**2016**, 118, 221–233. [Google Scholar] [CrossRef] - Song, S.; Cheng, C.; Pu, G.; An, F.; Luo, X. Global Remote Sensing Data Subdivision Organization Based on GeoSOT. Acta Geod. Cartogr. Sin.
**2014**, 43, 869–876. [Google Scholar] - Cheng, C.; Tong, X.; Chen, B.; Zhai, W. A Subdivision Method to Unify the Existing Latitude and Longitude Grids. ISPRS Int. J. Geo-Inf.
**2016**, 5, 161. [Google Scholar] [CrossRef] - Wang, R.; Ben, J.; Du, L.; Zhou, J.; Li, Z. Encoding and Operation for the Planar Aperture 4Hexagon Grid System. Acta Geod. Cartogr. Sin.
**2018**, 47, 1018–1025. [Google Scholar] - Xiaochong, T.; Jin, B.E.N.; Zhiyuan, Q.I.N.; Yongsheng, Z. The Subdivision of Partial Grid Based on Discrete Global Grid Systems. Acta Geod. Cartogr. Sin.
**2009**, 38, 506–513. [Google Scholar] - Xiaochong, T.; Jin, B.E.N.; Yongsheng, Z. The Subdivision of Global Multi-resolution Hexagonal Grid and the Rules of Address Coding. Acta Geod. Cartogr. Sin.
**2007**, 36, 428–435. [Google Scholar] - Goodchild, M.F.; Shiren, Y. A hierarchical spatial data structure for global geographic information systems. CVGIP Graph. Models Image Process.
**1992**, 54, 31–44. [Google Scholar] [CrossRef][Green Version] - Li, S.; Cheng, C.; Pu, G. QRA-Grid: Quantitative Risk Analysis and Grid-based Pre-warning Model for Urban Natural Gas Pipeline. ISPRS Int. J. Geo-Inf.
**2019**, 8, 122. [Google Scholar] [CrossRef][Green Version] - Li, S.; Hou, K.; Cheng, C.; Li, S.; Chen, B. A Space-Interconnection Algorithm for Satellite Constellation Based on Spatial Grid Model. Remote Sens.
**2020**, 12, 2131. [Google Scholar] [CrossRef] - Miao, S.; Cheng, C.; Zhai, W.; Ren, F.; Zhang, B.; Li, S.; Zhang, J.; Zhang, H. A Low-Altitude Flight Conflict Detection Algorithm Based on a Multilayer Grid Spatiotemporal Index. ISPRS Int. J. Geo-Inf.
**2019**, 8, 289. [Google Scholar] [CrossRef][Green Version] - Yang, M.; Cheng, C.; Chen, B. Mining Individual Similarity by Assessing Interactions with Personally Significant Places from GPS Trajectories. ISPRS Int. J. Geo-Inf.
**2018**, 7, 126. [Google Scholar] [CrossRef][Green Version] - Bradley, P.E.; Jahn, M.W. On the Behaviour of p-Adic Scaled Space Filling Curve Indices for High-Dimensional Data. Comput. J.
**2020**. [Google Scholar] [CrossRef] - Laurini, R.; Thompson, D. Fundamentals of Spatial Information Systems; Academic press: Cambridge, MA, USA, 1992; Volume 37. [Google Scholar]
- Jin, A.; Cheng, C. Spatial Data Coding Method Based on Global Subdivision Grid. J. Geomat. Sci. Technol.
**2013**, 30, 284–287. [Google Scholar] - Tong, X.; Ben, J.; Wang, Y.; Zhang, Y.; Pei, T. Efficient encoding and spatial operation scheme for aperture 4 hexagonal discrete global grid system. Int. J. Geogr. Inf. Sci.
**2013**, 27, 898–921. [Google Scholar] [CrossRef] - Zhou, X.; Tang, D.; Hao, L.; Song, Y. Application of earth partition gird theory in image processing. Sci. Surv. Mapp.
**2019**, 44, 84–89. [Google Scholar] - Li, S.; Pu, G.; Cheng, C.; Chen, B. Method for managing and querying geo-spatial data using a grid-code-array spatial index. Earth Sci. Inform.
**2019**, 12, 173–181. [Google Scholar] [CrossRef] - Open Geospatial Consortium Topic 21: Discrete Global Grid Systems Abstract Specification. Available online: https://docs.opengeospatial.org/as/15-104r5/15-104r5.html (accessed on 18 July 2021).
- Chen, J.; Li, C.M.; Li, Z.L.; Gold, C. A Voronoi-based 9-intersection model for spatial relations. Int. J. Geogr. Inf. Sci.
**2001**, 15, 201–220. [Google Scholar] [CrossRef] - Zhou, Y.; Wang, S.; Guan, Y. An Efficient Parallel Algorithm for Polygons Overlay Analysis. Appl. Sci.
**2019**, 9, 4857. [Google Scholar] [CrossRef][Green Version] - Moon, B.; Jagadish, H.V.; Faloutsos, C.; Saltz, J.H. Analysis of the clustering properties of the hilbert space-filling curve. IEEE Trans. Knowl. Data Eng.
**2001**, 13, 124–141. [Google Scholar] [CrossRef][Green Version] - Weiler, K.; Atherton, P. Hidden surface removal using polygon area sorting. ACM SIGGRAPH Comput. Graph.
**1977**, 11, 214–222. [Google Scholar] [CrossRef]

**Figure 1.**From the planet Earth to digital discrete Earth: (

**a**) planet Earth; (

**b**) digital discrete Earth.

**Figure 2.**GeoSOT-3D model: (

**a**) GeoSOT subdivision; (

**b**) GeoSOT-3D subdivision; (

**c**) Z-order filling curve.

**Figure 8.**Spatial orientation. (

**a**) shows the definition of the relative orientation of the grid. (

**b**) shows the definition of the absolute orientation of the grid.

**Figure 10.**Spatial calculation: (

**a**) neighboring directions; (

**b**) geometry meaning graph for parent grid operation (in 2D).

**Figure 12.**Spatial topological relationship between grids. (

**a**) Correspondence with DE-9IM; (

**b**) spatial topological relationship between grids (3D).

**Figure 18.**Experiments of overlay: layer (

**a**) and layer (

**b**) are the layers to be overlaid that have only one area object; layer (

**c**) is the result of the overlay. The pink and green areas are the original areas. The purple area is the overlaid area.

**Figure 19.**Experiments of overlay: layer (

**a**) is a layer with multiple area objects. We moved (

**a**) along the x-axis and formed a new layer, which was overlaid with the old layer (

**a**). Layer (

**b**) is the result of the overlay.

Method | First | Second | Third | Average |
---|---|---|---|---|

Convert Hilbert curve to (x,y)(ms) | 179 | 182 | 181 | 180 |

Displacement calculation under Z-order(ms) | 11 | 12 | 10 | 11 |

Method | First | Second | Third | Average |
---|---|---|---|---|

algebraic operation (ms) | 175 | 182 | 183 | 180 |

Weiler–Atherton algorithm (ms) | 232 | 237 | 243 | 237 |

Method | First | Second | Third | Average |
---|---|---|---|---|

algebraic operation (ms) | 752 | 753 | 748 | 751 |

Weiler–Atherton algorithm (ms) | 4807 | 4910 | 4781 | 4836 |

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Hou, K.; Cheng, C.; Chen, B.; Zhang, C.; He, L.; Meng, L.; Li, S. A Set of Integral Grid-Coding Algebraic Operations Based on GeoSOT-3D. *ISPRS Int. J. Geo-Inf.* **2021**, *10*, 489.
https://doi.org/10.3390/ijgi10070489

**AMA Style**

Hou K, Cheng C, Chen B, Zhang C, He L, Meng L, Li S. A Set of Integral Grid-Coding Algebraic Operations Based on GeoSOT-3D. *ISPRS International Journal of Geo-Information*. 2021; 10(7):489.
https://doi.org/10.3390/ijgi10070489

**Chicago/Turabian Style**

Hou, Kaihua, Chengqi Cheng, Bo Chen, Chi Zhang, Liesong He, Li Meng, and Shuang Li. 2021. "A Set of Integral Grid-Coding Algebraic Operations Based on GeoSOT-3D" *ISPRS International Journal of Geo-Information* 10, no. 7: 489.
https://doi.org/10.3390/ijgi10070489