# A Space-Interconnection Algorithm for Satellite Constellation Based on Spatial Grid Model
## 2 Methods
### Satellite Grid Visibility Algorithm
#### 2.2.2 Grid Visibility Analysis  
In this section, we construct a grid visibility analysis method based on the aerospace grid indexing BigTable, including the satellite visibility grid lookup table and grid calculation method.  
(i) Satellite visibility grid lookup table  
The structure definition of the aerospace grid indexing BigTable is presented in Section 2.1.2, which contains the column \"visible\". The type of this column is an array, which can store one or more codes of visible grids. Here we will provide samples of two grids in BigTable, one with data and the other without data. The column \"data\" can add or remove attributes.  
As can be seen in Figure 5, the grid code \"visible\" is an inherent property of the grid. Whether the grid has data or not, there will be a corresponding \"visible\" grid (or set). When querying the \"visible\" grid or set of a grid, the corresponding query statement is entered. After creating a satellite visibility grid look-up table, querying the \"visible\" field shows that a grid may have many geometrically visible grids. The ground station does not need to consider the storage cost and can store all grids. However, the storage resources on the satellite are limited; hence, it is necessary to optimize the satellite visibility grid look-up table. Because satellite movement has periodicity, we can store all the visibility grids of a certain satellite at different times on the satellite when performing storage optimization, and we can match the geometric visibility grids according to the periodic running time. If the impact of satellite orbit perturbation has to be considered, we can periodically go to the background to calculate and update the view grid.  
(ii) Grid Visibility Calculation  
This section will then discuss how to calculate the visibility of the two grids. The principle of grid geometric visibility calculation is to calculate the grid code set of links between satellites, and then  
Figure 4: Geometric visibility between satellites.  
judge whether the height code is blocked by the earth or the atmosphere, in order to realize the geometric visibility calculation between satellites.  
Step 1: Calculate the inter-satellite grid code set. Based on the 3D Bresenham algorithm, the path between two target grids is filled with grids with adjacent edges or corners [38].  
Step 2: Compare height codes. Compare the minimum elevation code in the grid code set with the height code for the occlusion height (Equation (4)):  
\[\textit{min}\ (H_{\textit{codes}})<H_{\textit{code}(\textit{Rearth+hatm})} \tag{4}\]  
where \(H_{\textit{codes}}\) is the inter-satellite grid code set, and \(H_{\textit{code}\ (\textit{Rearth+hatm})}\) is the height code of the Earth and atmosphere.  
The advantage of the algorithm is that it does not need to determine whether satellites are in the same orbit (calculations of different orbits are complicated), and the high-dimensional floating operations are converted into comparisons between one-dimensional height codes. After all visible grids of the grid are calculated in advance, they can be stored in the grid visibility look-up table and become an inherent property of the grid. When one satellite moves into the visible grid of the grid in which the other satellite is located, the two satellites are geometrically visible.  
In addition, based on geometric visibility analysis, combined with the code azimuth calculation and distance measurement algorithms, we can further analyze the antenna visibility and impact of distance, and then achieve a more accurate visibility calculation between satellites.