# A GNSS/5G Integrated Three-Dimensional Positioning Scheme Based on D2D Communication
## 2 Methods
### GNSS/5G Integrated Three-Dimensional Positioning Scheme
#### 2.3.1 GNSS/5G Integrated Three-Dimensional Positioning Based on DBSCAN
We also take the clustering result based on the TOA measurements, for example, and the weighting process is as follows. As mentioned in DATM, \(p_{t,h}=\left(x_{t,h},y_{t,h},z_{t,h}\right)\) is the mean value of the \(h\)th cluster, which indicate the position of an MU. We assumed that there are \(b_{h}\) data points in the \(h\)th cluster denoted as \(\mathcal{CK}_{t,h}=\left\{pc_{t,1},\cdots,pc_{t,g},\cdots,pc_{t,b_{h}}\right\}\), where \(pc_{t,g}=\left(xc_{t,g,}yc_{t,g},zc_{t,g}\right)\). Then, the variance of the east, north and up coordinate in the \(h\)th cluster is shown respectively as  
\[vx_{t,h}=\sum_{g=1}^{b_{h}}\left(x_{t,h}-xc_{t,g}\right)^{2} \tag{15}\]  
\[vy_{t,h}=\sum_{g=1}^{b_{h}}\left(y_{t,h}-yc_{t,g}\right)^{2} \tag{16}\]  
\[vz_{t,h}=\sum_{g=1}^{b_{h}}\left(z_{t,h}-zc_{t,g}\right)^{2} \tag{17}\]  
Accordingly, we can obtain \(vx_{r,h}\), \(vy_{r,h}\) and \(vz_{r,h}\) for the \(h\)th cluster based on the RSS measurements. Since the distribution in the east, north and up coordinate may be different, we integrate the clustering results in different coordinates, respectively. Then, we define the position based on the joint TOA/RSS method as \(p_{tr,h}=\left(x_{tr,h},y_{tr,h},z_{tr,h}\right)\), where \(x_{tr,h}\), \(y_{tr,h}\) and \(z_{tr,h}\) are respectively represented as [35]  
\[x_{tr,h}=\frac{\frac{1}{\sqrt{\sqrt{vx_{t,h}}}}}{\frac{1}{\sqrt{vx_{t,h}}}+ \frac{1}{\sqrt{vx_{t,h}}}}x_{t,h}+\frac{\frac{1}{\sqrt{vx_{t,h}}}}{\frac{1}{ \sqrt{vx_{t,h}}}+\frac{1}{\sqrt{vx_{t,h}}}  
Here, we obtain the positions based on the joint TOA/RSS method after the DBSCAN algorithm, represented as \(\mathcal{P}_{tr}=\{p_{tr,1},p_{tr,2},\cdots,p_{tr,u}\}\). ```
Input: \(\mathcal{K}^{t}=\{\mathcal{K}_{t,1},\cdots,\mathcal{K}_{t,i},\cdots,\mathcal{K}_ {t,N}\}\), (\(e\), \(Min\)Pts)
1: Initialization: Let \(\Omega=\varnothing\) be the set of core objects, \(u=0\) be the number of clusters and \(\Gamma=\mathcal{K}^{t}\) be the sample data set unvisited
2:for all\(r\in\mathcal{K}^{t}\)do
3: determine the \(e-\)_neighborhood_ of data point \(dp_{r}\) as \(N_{e}(dp_{r})=\{dp_{s}\in\mathcal{K}^{t}|dist(dp_{r},dp_{s})\leq e\}\) defined in (13)
4:if\(|N_{e}(dp_{r})|\geq Min\)Ptsthen
5:\(dp_{r}\) is added to the set of the core objects: \(\Omega=\Omega\cup\{dp_{r}\}\)
6:end
7:end
8:while\(\Omega=\varnothing\)do
9: set the current unvisited sample data set as \(\Gamma_{old}=\Gamma\), select a core object \(o\in\Omega\) and denote a queue as \(Q=\langle o\rangle\), then \(\Gamma=\Gamma\backslash\{o\}\)
10:while\(Q\
eq\varnothing\)do
11: extract the first data point \(q\) in \(Q\)
12:if\(|N_{e}(q)|\geq Min\)Ptsthen
13:\(\Delta=N_{e}(q)\cap\Gamma\) and add the data points in \(\Delta\) to \(Q\), \(\Gamma=\Gamma\backslash\Delta\)
14:end
15:end
16:\(u=u+1\) and the formed cluster is \(C_{t,u}=\Gamma_{old}\backslash\Gamma\)
17:\(\Omega=\Omega\backslash C_{t,u}\)
18:end
19: Output the clustering result \(\mathcal{C}^{t}=\{C_{t,1},C_{t,2},\cdots,C_{t,u}\}\) and calculate the mean value of each cluster in \(\mathcal{C}^{t}\) denoted as \(\mathcal{P}\mathcal{C}^{t}=\{p_{t,1},p_{t,2},\cdots,p_{t,u}\}\)
```  
**Algorithm 1**DBSCAN Algorithm Based on The TOA Measurements (DATM)