## 2 Methods
### Sort the Set of Ships Available for Rescue According to the Distance from the Ship in Distress  
Generally speaking, the ship closest to the ship in distress is the most effective in carrying out rescue, but considering the rescue effect, rescue capability, and the possibility of participation in the rescue, it is also necessary to provide alternative ships within the effective rescue distance according to the distance from the ship in distress. Therefore, it is necessary to rank the set of ships available for rescue based on the distance from the ship in distress according to the different grid coding levels. As shown in Figure 2, the yellow and blue grids represent the spatial regions corresponding to the two adjacent coding levels of Google S2. When the ship in distress is located at point a, if the ship available for rescue cannot be found within the yellow grid region where point a is located, the scope can be expanded to search in the previous level of encoder region A. However, when the ship in distress is located at point b, if the ship available for rescue cannot be found within the yellow grid region where point b is located, there are two methods: (1) expanding the scope to search in the previous level of encoder region A, or (2) to retrieve in its neighboring grid coding region B. Obviously, rescue ship c in region B is closer to the ship in distress b than rescue ship d in region A, therefore it is more suitable for rescue. Therefore, to solve the above problem, we propose an \"Alternating Grid Sorting Based on Neighborhoods and Different Coding Levels\" algorithm, as shown in Figure 3. \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline \multirow{2}{*}{**Speed (Nautical Miles/h)**} & \multicolumn{6}{c}{**Rescue Time/h**} \\ \cline{2-7}  & **0.5** & **1** & **1.5** & **2** & **3** & **12** \\ \hline
8 (Fishing boat and Transport ship) & 10 & 09 & 09 & 08 & 08 & 06 \\
9 (Fishing boat and Transport ship) & 10 & 09 & 09 & 08 & 08 & 06 \\
10 (Fishing boat and Transport ship) & 10 & 09 & 08 & 08 & 07 & 05 \\
15 (Professional rescue ship) & 10 & 08 & 08 & 07 & 07 & 05 \\
20 (Professional rescue ship) & 09 & 08 & 07 & 07 & 06 & 04 \\
25 (Professional rescue ship) & 09 & 08 & 07 & 07 & 06 & 04 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Coding level of effective rescue distance corresponding to rescue time. When a ship is in distress at sea, if there are other ships within 3 km of it, it can be rescued directly without reporting. Therefore, we set the minimum value of the search distance to 3 km, and the corresponding gridcode level is 11. When querying the rescue time of the ship in distress and the set \(S\) of ships available for rescue within the distance, the following needs to occur: (1) determine the effective rescue distance and corresponding Google S2 encoding level; (2) query whether there is a ship that meets the conditions in \(SOA\) based on the grid code and store the result in \(SOA\_MD\) (3); calculate the grid code of the eight neighboring domains around the grid code, query them sequentially in \(SOA\), and save the result in \(SOA\_MD\); (4) calculate the coding result grid code with coding level 10 on the previous level of the grid code; (5) repeat steps (2), (3), and (4) until the coding level of the grid code is less than the coding level within the rescue time and effective  
Figure 3: Alternative grid sorting based on neighborhood and different coding levels. Figure 2: Google S2 algorithm based retrieval of ships in distress for available rescue ships. Point a and b represent ships in distress in two different situations, point c and d that need to be retrieved in the searching process, represent the most neighboring ships available for rescue for ship a and b, and A and B represent the spatial retrieval region of ships in distress for ships that are available for rescue. rescue distance; and (6) output the \(SOA\_MD\) of the set of ships available for rescue sorted according to the distance from the ship in distress. The specific algorithm is shown in Algorithm 3.