# An Efficient GNSS Coordinate Recognition Algorithm for Epidemic Management
## 4 Coordinate Recognition Algorithm
### The Proposed Algorithm
```
1\(R:=\) RectOffy(\(P\));
2\(x_{min}:=R[0]\); xmax\(:=\) R[1]; ymin\(:=\) R[2]; ymax\(:=\) R[3];
3\(SS:=\) RectPntToSqr (\(x_{min}\), \(x_{max}\), \(y_{min}\), \(y_{max}\), \(sl\));
4\(G_{P}:=\emptyset\); \(G_{T}:=\emptyset\);
5 for each \(s_{0}\)in \(SS\)do
6\(s_{0}:=(s_{0,\times},s_{0,y})\);
7\(s_{1}:=(s_{0,\times}+sl,s_{0,y})\);
8\(s_{2}:=(s_{0,\times}-sl,s_{0,y}-sl)\) ;
9\(s_{3}:=(s_{0,\times},s_{0,y}-sl)\);
10\(s_{4}:=s_{0}\);
11\(S:=\)[\(s_{0}\), \(s_{1}\), \(s_{2}\), \(s_{3}\), \(s_{4}\)];
12\(status:=\) SqrInPy(\(S\), \(P\));
13 ifstatus\(=0\)orstatus\(=1\)then
14\(G_{T}:=\)[SELECT * FROM 'G' WHERE 'x' \(\geq\)\(s_{0,\times}\) AND 'y' \(\geq\)\(s_{0,y}\) AND 'x' \(>\)\((s_{0,\times}+r)\) AND 'y' \(>\)\((s_{0,y}+r)\)];
15 endif
16 ifstatus\(=0\)then
17\(G_{P}:=G_{P}\cup G_{T}\);
18 endif
19 ifstatus\(=1\)then
20 for each \(g\)in \(G_{T}\)do
21 ifPntInPy(\(g\), \(P\)) \(=1\)then\(G_{P}:=G_{P}\cup\{g\}\); endif
22 endfor
23 endif
24 endfor
25 return(\(G_{P}\));
```  
**Algorithm 6**CoordRecognit (polygon \(P\), point set \(G\), side length \(sl\))  
Algorithm 8 is the CoordRecognit algorithm. It is a coordinate recognition algorithm, and its inputs are a polygon \(P\), a point set \(G\), and the side length \(r\) of a square. Applying it will return all inner points of polygon \(P\). This algorithm first defines a rectangle \(R\), which can cover polygon \(P\), through RectOffy. Next, this rectangle \(R\) is partitioned into \(SS\), a set of squares \(SS\) with a side length \(sl\), through RectPntToSquare. For each square \(s_{0}\) of \(SS\), where \(s_{0}\) is the upper-left vertex of the square, its vertices are composed of a square \(S=\{s_{0},s_{1},s_{2},\)\(s_{3},s_{4}(=s_{0})\}\). Then, the space-overlap status between square \(S\) and polygon \(P\) is evaluated through SqrInPy. If \(S\) is an inner square of or a square intersecting with polygon \(P\), i.e., \(status=0\)**or**\(status=1\), the SQL statement is queried in order to retrieve the inner points from table 'Q', and they are stored in set \(G_{T}\). If \(S\) is an inner square of \(P\), i.e., \(status=0\), set \(G_{T}\) is directly stored in set \(G_{P}\). If \(S\) is a square intersecting with \(P\), i.e., \(status=1\), each point \(g\) of \(G_{P}\) must be confirmed through PntInPy. If point \(g\) is an inner point of \(P\), incrementally, point \(g\) is stored in \(G_{P}\). Finally, \(G_{P}\) is the set of all inner points of \(P\). ```
1\(R:=\) RectOffy(\(P\));
2\(x_{min}:=R[0]\); xmax\(:=\) R[1]; ymin\(:=\) R[2]; ymax\(:=\) R[3];
3\(SS:=\) RectPntToSqr (\(x_{min}\), \(x_{max}\), \(y_{min}\), \(y_{max}\), \(sl\));
4\(G_{P}:=\emptyset\); \(G_{T}:=\emptyset\);
5 for each \(s_{0}\)in \(SS\)do
6\(s_{0}:=(s_{0,\times},s_{0,y})\);
7\(s_{1}:=(s_{0,\times}+sl,s_{0,y})\);
8\(s_{2}:=(s_{0,\times}-sl,s_{0,y}-sl)\);
9\(s_{3}:=(s_{0,\times},s_{0,y}-sl)\);
10\(s_{4}:=s_{0}\);
11\(S:=\)[\(s_{0}\), \(s_{1}\), \(s_{2}\), \(s_{3}\), \(s_{4}\)];
12\(status:=\) SqrInPy(\(S\), \(P\));
13 ifstatus\(=0\)orstatus\(=1\)then
14\(G_{T}:=\)[SELECT * FROM 'G' WHERE 'x' \(\geq\)\(s_{0,\times}\) AND 'y' \(\geq\)\(s_{0,\times}\) AND 'x' \(>\)\((s_{0,\times}+r)\) AND 'y' \(>\)\((s_{0,\times}+r)\)];
15 endif
16 ifstatus\(=0\)then
17\(G_{P}:=G_{P}\cup G_{T}\);
18 endif
19 ifstatus\(=1\)then
20 for each \(g\)in \(G_{T}\)do
21 ifPntInPy(\(g\), \(P\)) \(=1\)then\(G_{P}:=G_{P}\cup\{g\}\); endif
23 endif
24 endfor
25 return(\(G_{P}\));
```  
**Algorithm 9**CoordRecognit (polygon \(P\), point set \(G\), side length \(sl\))  
Algorithm 10