## 2 Methods
### Geographical Grid Coding of Ship Positions Based on Google S2  
In order to facilitate the retrieval of ships available for rescue in the current sea area and the current period, it is necessary to store the position information reported by ships in the current sea area in real time. Fields are established in the database as the unique identification code, the ship identification code, the ship name, the timestamp of the ship position, the latitude and longitude of the ship's position, the vessel's speed and direction, the Google S2 code, the ship type, and ship type identification code. When the information about a ship's position is obtained, it is coded using Google S2. The detailed field information of the table storing the vessel's position is shown in Table 1.  
Google S2 coding is a grid coding algorithm applied to geospatial neighborhoods proposed by Google in 2011, similar to the GeoHash algorithm [32]. The Google S2 algorithm performs a series of transformations of longitude and latitude, which is finally converted to CellID on the Hilbert curve. Then, by comparing the values of CellID to determine if they are in the same area. The maximum coding level of Google S2 is 30, and the corresponding spatial area size is 0.48 cm\({}^{2}\), so it can meet most of the application scenarios. The Google S2 algorithm is built on the Hilbert curve. The Hilbert curve has good dimensionality reduction. When \(n\) tends to infinity, the \(n\)-order Hilbert curve can be approximated to fill the whole plane. In addition, it has better stability. The points adjacent to each other on the Hilbert curve in the original space must be adjacent. Finally, the Hilbert curve is continuous so that it is guaranteed to fill the whole space [30;31]. The Google S2 coding algorithm is shown in Algorithm 1, where _lon_ indicates longitude, _lat_ indicates latitude, and _pre_ indicates code length.  
```
Input:\(L\), \(L\), \(Pre\) Output:\(CellID\) // Step 1: Convert longitude and latitude to radians \(Lat\), \(Lan\)\(\rightarrow\)\(\leftarrow\)\(\leftarrow\) (lat, lon) // Step 2: Establish a three-dimensional coordinate system with the center of the earth as the origin, and convert the longitude and latitude into points on the spherical rectangular coordinate system \(\lx@sectionsign\) (lat, \(on\)) \(\rightarrow\)\(\lx@sectionsign\) (\(x\), \(y\), \(z\)) // Step 3: Spherical variable plane \(f(x,y,z)\)\(\rightarrow\) (fecec, \(u\), \(v\)) // Step 4: Spherical rectangular projection correction \(g\) (fec, \(u\), \(v\))\(\rightarrow\)\(\lx@sectionsign\) (\(fac\), \(s\), \(l\)) // Step 5: Conversion between points and coordinate axis points \(h\) (\(fac\), \(s\), \(t\)) // Step 6: Axis points are converted to values on the corresponding hierarchical Hilbert curves, which are combined with faceted representations to form CellID \(H\) (\(fac\), \(i\), \(j\))\(\rightarrow\)CellID returnCellID
```  
**Algorithm 1**Google S2 encoding algorithm  
\begin{table}
\begin{tabular}{c c c c} \hline
**Column Name** & **Data Type** & **Null/Not Null** & **Comments** \\ \hline ID & int & Not Null & Unique identification code \\ ShipID & int & Not Null & Ship identification code \\ ShipName & varchar (50) & Not Null & Ship’s Name \\ Time & datetime & Not Null & Timestamp of position \\ Longitude & float & Not Null & Longitude of position \\ Latitude & float & Not Null & Latitude of position \\ Speed & float & Not Null & Vessel’s speed \\ Direction & float & Not Null & Vessel’s direction \\ GridCode & varchar (50) & Not Null & Google S2 Code to the ship’s position \\ ShipType & varchar (50) & Not Null & Ship Type \\ ShipTypeID & int & Not Null & Vessel Type ID \\ \hline \end{tabular}
\end{table}
Table 1: Vessel data storage record table named as gridcode_vessels.