# Improving Smartphone GNSS Positioning Accuracy Using Inequality Constraints
## 2 Positioning Model and Inequality Constraints
#### 2.2.1 Vertical Velocity Constraint  
Because of the limitation of road slope and the velocity of vehicles, there could be an upper bound of velocity in the up component. For instance, the Highway Technique Standard has a speed limitation of 120 km/h and a slope limitation of 3% on highways [37]; in this case, the range of the vertical velocity should be \(-1\) m/s\(\sim\)1 m/s. In other words, even if the horizontal velocity of smartphones is unknown, we can still set an empirical threshold for vertical velocity in most cases. In this part, the threshold is expressed using the following inequation:  
\[|v_{u}|\leq\sigma_{u} \tag{4}\]  
where \(v_{u}\) represents vertical velocity, and \(\sigma_{u}\) represent the threshold in \(m/s\). Note that this inequation is established under the body system and is not directly applicable. We must first convert the results from the WGS84 system to the body system. In addition, considering that after constraining the position can be changed, iteration is necessary for the results to fit the velocity inequation condition. To avoid complex and low-efficiency iteration procedures, we transform velocity into position change. Assuming that the interval is \(\Delta t\), we can calculate the height constraints of continuous epochs as follows:  
\[\sigma_{h}=\sigma_{u}\times\Delta t \tag{5}\]  
where \(\sigma_{h}\) represents the threshold of the height change in meters, and \(\Delta t\) represents the sampling interval in seconds. In this paper, the sampling interval is 1 s. Additionally, the vertical velocity constraint can be converted as follows:  
\[|h_{t+1}-h_{t}|\leq\sigma_{h} \tag{6}\]  
where \(t\) and \(t+1\) represent different epochs, \(h_{t+1}\) and \(h_{t}\) represent the height in two epochs. Regarding coordinate system conversion, we can choose a position \(p_{0}\) near the smartphone as the reference, and this position can be calculated using the SPP algorithm. The transform matrix can be computed as follows based on the reference \(p_{0}\):  
\[\mathbf{E_{0}}= \begin{bmatrix}-\sin l&\cos l&0\\ -\sin b\cos l&-\sin b\sin l&\cos b\\ \cos b\cos l&\cos b\sin l&\sin b\end{bmatrix}  \tag{7}\]  
where \(\mathbf{E}_{0}\) represents the conversion matrix, and \(b\) and \(l\) represent the latitude and longitude of the reference \(p_{0}\). With this conversion matrix, we can compute the height difference of continuous epochs as follows:  
\[h_{t+1}-h_{t}= \begin{bmatrix}\cos b\cos l&\cos b\sin l&\sin b\end{bmatrix} (r_ {t+1}-r_{t}) \tag{8}\]  
It should be noted that only the third row in \(\mathbf{E}_{0}\) is selected since only the height component is applied. In addition, considering that the symbol of absolute value is utilized in Equation (6), we can express the inequation as follows:  
\[\left\{ \begin{array}{ccc}\cos b\cos l&\cos b\sin l&\sin b\end{array} \right] (\mathbf{r}_{t+1}-\mathbf{r}_{t})\leq\sigma_{h}\\ -\cos b\cos l&-\cos b\sin l&-\sin b\end{bmatrix}(\mathbf{r}_{t+1}-\mathbf{r}_{t})\leq \sigma_{h} \tag{9}\]  
The change in position between continuous epochs can be computed using the velocity, the acceleration, and the sampling interval. The position in the above inequality can be written as:  
\[\mathbf{r}_{t+1}-\mathbf{r}_{t}=\mathbf{v}_{t}\Delta t+0.5\mathbf{a}_{t}\Delta t^{2} \tag{10}\]Overall, upon applying the empirical vertical velocity information, we can establish the constraint matrix as follows:  
\[\left\{ \begin{array}{l}\overline{\mathbf{E}}_{0}=\left[\begin{array}{ccc}\cos b \cos l&\cos b\sin l&\sin b\\ -\cos b\cos l&-\cos b\sin l&-\sin b\end{array}\right]\\ \mathbf{C_{0}}=\left[\begin{array}{cc}\mathbf{0}_{2\times 3}&\overline{\mathbf{E}}_{0} \Delta t&0.5\overline{\mathbf{E}}_{0}\Delta t^{2}\end{array}\right]\\ \mathbf{d_{0}}=\left[\begin{array}{cc}\sigma_{h}&\sigma_{h}\end{array}\right]^{ \mathsf{T}}\end{array} \right. \tag{11}\]  
where \(\overline{\mathbf{E}}_{0}\) represents the third row of \(\mathbf{E}_{0}\), \(\mathbf{C_{0}}\) and \(\mathbf{d_{0}}\) are the constraint matrices.