# Improving Smartphone GNSS Positioning Accuracy Using Inequality Constraints
## 2 Positioning Model and Inequality Constraints
#### 2.2.2 Direction Constraint  
In some cases, the moving direction of a smartphone or vehicle can be obtained. For instance, its direction can be calculated by the road nodes in a digital map, such as the Open Street Map (OSM), which can be downloaded onto a smartphone. An example is given below, with some of the elements of an OSM shown in Figure 1. In this figure, the black lines represent roads, and the red points represent the nodes of the roads. The latitude and longitude of the four nodes are given in Table 1. Assuming that the vehicle moved from east to west, we can calculate the direction: \(\alpha_{D\to A}=260.48^{\circ}\), and \(\alpha_{B\to C}=248.59^{\circ}\). Additionally, this information can be used as constraints in a positioning campaign. We can set a range when applying direction information. Additionally, we can employ the position change in the body system to estimate direction. The direction constraint at this stage can be written as follows:  
\[\left|\tan^{-1}\frac{\Delta x_{et}}{\Delta x_{nt}}-\alpha_{t}\right|\leq\delta \tag{13}\] \begin{table}
\begin{tabular}{c c c c c} \hline \hline  & **A** & **B** & **C** & **D** \\ \hline Latitude (\({}^{\circ}\)) & 31.893451 & 31.8936597 & 31.8933643 & 31.8935834 \\ \hline Longitude (\({}^{\circ}\)) & 118.8175719 & 118.8184759 & 118.817593 & 118.818498 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Latitude and longitude of the four nodes. Figure 1: Roads and nodes downloaded from OSM. where \(\alpha_{t}\) represents the prior direction, and \(\delta\) represents the threshold, which is determined by the tolerance range of the direction. \(\Delta x_{et}\) and \(\Delta x_{nt}\) represent the east and north position changes in meters. Similar to Equation (8), they can be calculated as follows:  
\[\left\{ \begin{array}{l}\Delta x_{et}=\left[\begin{array}{ccc}-\sin l&\cos l &0\end{array}\right](\mathbf{r}_{t+1}-\mathbf{r}_{t})\\ \Delta x_{nt}=\left[\begin{array}{ccc}-\sin b\cos l&-\sin b\sin l&\cos b\end{array} \right](\mathbf{r}_{t+1}-\mathbf{r}_{t})\end{array} \right. \tag{14}\]  
This is an inverse trigonometric function and a fraction in Equation (13). It is difficult to convert this inequality into a linear form. In this paper, we propose several steps to achieve the above direction inequality constraint. In the first step, we can compute the initial direction using the unconstrained position results. If the direction is within the given range, the constraint is not necessary. If the direction is outside the range, we proceed to the second step, in which we convert the position change result from the body system to a new coordinate system, as shown in Figure 2. As shown in the figure, the direction can be limited to a range of \(-\delta\sim\delta\) after conversion. Additionally, the rotation method is introduced in Equation (15). \[ \begin{bmatrix}\Delta\hat{x}_{et}\\ \Delta\hat{x}_{nt}\end{bmatrix} = \begin{bmatrix}\cos\alpha_{t}&-\sin\alpha_{t} \\ \sin\alpha_{t}&\cos\alpha_{t}\end{bmatrix}\begin{bmatrix}\Delta x_{et}\\ \Delta x_{nt}\end{bmatrix}  \tag{15}\]  
In Equation (15), \(\Delta\hat{x}_{et}\) and \(\Delta\hat{x}_{nt}\) represent the converted position change. A new inequality can be obtained as follows:  
\[-\delta\leq\tan^{-1}\frac{\Delta\hat{x}_{et}}{\Delta\hat{x}_{nt}}\leq\delta \tag{16}\]  
Assuming that \(\delta\) is smaller than \(\pi/2\), we can obtain the inequality in linear form as follows:  
\[\left\{ \begin{array}{l}\Delta\hat{x}_{nt}\geq 0\\ \Delta\hat{x}_{et}-\Delta\hat{x}_{nt}\tan\delta\leq 0\\ -\Delta\hat{x}_{et}-\Delta\hat{x}_{nt}\tan\delta\leq 0\end{array} \right. \tag{17}\]  
Figure 2: Position change conversion from the body system to a new coordinate system. The third step is to build the constraint matrix for direction inequality constraints based on all the aforementioned equations. The constraint matrix, considering direction, can be established as follows:  
\[\left\{