# A Spatial-Temporal-Semantic Neural Network Algorithm for Location Prediction on Moving Objects
## 3 Methodology
### Spatial-Temporal-Semantic Feature Extraction
#### 3.1.2 Geographical Feature Matching  
Same as time factor, the geographical information of trajectory such as coordinate is continuous in space, which is difficult to use in a model. Trajectory should be converted to fixed reference points. Existing methods utilizing cell-based partitioning, clustering, and stop point detection cannot handle points on the road. Therefore, a new geographical feature mapping method is proposed to transform all the points in a trajectory. Objects always travel along the road in the city, therefore, the city road networks are selected as reference points. Open Street Map (OSM) is a project that creates and distributes free geographic data for the world [24]. Map data from OSM is in _.osm_ format. It contains all elements including points of interest, roads, and regions, as shown in Figure 7.  
Each road can be represented as a line \(l_{i}=(n_{s},n_{e})\), with a start node \(n_{s}=(lon_{s},lat_{s})\) and an end node \(n_{e}=(lon_{e},lat_{e})\). First, for each track point \(p_{i}\), find the nearest line \(l_{near-i}\) by sorting the distance from \(p_{i}\) to all lines in the network. The searching could be time consuming when the network is very large. However, with the indexing technology used in geo-database such as PostgreSQL, the process could be executed in milliseconds. The projection point \(p_{j}=(lon_{j},lat_{j})\) of \(p_{i}\) on \(l_{neari}\) is calculated by Equation (3), shown as the red points in Figure 8a, where \(k\) is the slope of \(l_{neari}\):  
\[lon_{j}=\frac{k\cdot lon_{s}+lon_{i}/k+lat_{i}-lat_{s}}{1/k+k} \tag{3}\]  
Figure 6: Process of the mapping of time bins.  
Figure 7: The road network data of Beijing, used as reference points in the geo-feature mapping.  
\[lat_{j}=-\frac{1}{k}\cdot\left(lon_{j}-lon_{i}\right)+lat_{i}.\]  
The projection point could be anywhere on the line, which is not discrete. Several fixed points on the line are set by the distance parameter \(\mathit{Threshold}_{d}\). According to the precision required by different applications, \(\mathit{Threshold}_{d}\) could be 5 m, 10 m, or 15 m, smaller than the length of the road. The length of road \(l_{i}\) is calculated by Equation (4), where \(\varphi_{1}\) is the radian of \(lat_{s}\), \(\varphi_{2}\) is the radian of \(lat_{e}\), \(\Delta\varphi\) is the radian of \(lon_{s}-lon_{e}\), and \(\Delta\varphi\) is the radian of \(lat_{s}-lat_{e}\). \(R\) is the radius of the earth, which depends on the mapping implementation, and a good choice for the radius is the mean earth radius, \(R\approx 6371\) km (for the WGS84 ellipsoid). Then, the line is divided into \(k=\mathit{Ceil}\ \left(L/\mathit{Threshold}_{d}\right)\) segments. The fixed points in line \(l_{i}\) can be calculated by \(n_{s}\), \(n_{e}\), and \(k\), as shown in Figure 8b. Finally, each projection point is mapped to the nearest fixed points, so do the original track points, as shown in Figure 8c.  
\[L=2\cdot R\cdot\arcsin\sqrt{\sin^{2}(\Delta\varphi/2)+\cos\varphi_{1}\cdot \cos\varphi_{2}\cdot\sin^{2}(\Delta\lambda/2)}. \tag{4}\]  
After the mapping of temporal and geographic features, the original trajectory is transformed into \(T_{ST}=\{l_{i}|l_{i}=(n_{s1},n_{s2},\ldots,n_{e})\}\), represented by a series of lines \(l_{i}\) in the road network, and each line consists of several fixed points \(n_{si}\).