Skip to main content
Log in

Algorithms for Nearest Neighbor Search on Moving Object Trajectories

  • Published:
GeoInformatica Aims and scope Submit manuscript

Abstract

Nearest Neighbor (NN) search has been in the core of spatial and spatiotemporal database research during the last decade. The literature on NN query processing algorithms so far deals with either stationary or moving query points over static datasets or future (predicted) locations over a set of continuously moving points. With the increasing number of Mobile Location Services (MLS), the need for effective k-NN query processing over historical trajectory data has become the vehicle for data analysis, thus improving existing or even proposing new services. In this paper, we investigate mechanisms to perform NN search on R-tree-like structures storing historical information about moving object trajectories. The proposed (depth-first and best-first) algorithms vary with respect to the type of the query object (stationary or moving point) as well as the type of the query result (historical continuous or not), thus resulting in four types of NN queries. We also propose novel metrics to support our search ordering and pruning strategies. Using the implementation of the proposed algorithms on two members of the R-tree family for trajectory data (namely, the TB-tree and the 3D-R-tree), we demonstrate their scalability and efficiency through an extensive experimental study using large synthetic and real datasets.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Institutional subscriptions

Figure 1
Figure 2
Figure 3
Figure 4
Figure 5
Figure 6
Figure 7
Figure 8
Figure 9
Figure 10
Figure 11
Figure 12
Figure 13
Figure 14
Figure 15
Figure 16
Figure 17
Figure 18
Figure 19
Figure 20
Figure 21
Figure 22
Figure 23
Figure 24
Figure 25

Similar content being viewed by others

References

  1. R. Benetis, C. Jensen, G. Karciauskas, and S. Saltenis. “Nearest neighbor and reverse nearest neighbor queries for moving objects,” in Proceedings of IDEAS, 2002.

  2. S. Babu and J. Widom. “Continuous queries over data streams,” SIGMOD Record, Vol. 30(3):109–120, 2001 (September).

    Article  Google Scholar 

  3. K.L. Cheung and A.W. Fu. “Enhanced nearest neighbour search on the R-tree,” SIGMOD Record, Vol. 27(3):16–21, 1998 (September).

    Article  Google Scholar 

  4. A. Guttman. “Rtrees: A dynamic index structure for spatial searching,” in Proceedings of ACM SIGMOD, 1984.

  5. G. Hjaltason and H. Samet. “Distance browsing in spatial databases,” ACM Transactions on Database Systems, Vol. 24(2):265–318, 1999.

    Article  Google Scholar 

  6. H. Hu, J. Xu, and D.L. Lee. “A generic framework for monitoring continuous spatial queries over moving objects,” in Proceedings of ACM SIGMOD, 2005.

  7. G.S. Iwerks, H. Samet, and K. Smith, “Continuous K-nearest neighbor queries for continuously moving points with updates,” in Proceedings of VLDB, 2003.

  8. Y. Manolopoulos, A. Nanopoulos, A.N. Papadopoulos, and Y. Theodoridis. R-trees: Theory and Applications. Springer: Berlin Heidelberg New York, 2005.

    Google Scholar 

  9. K. Mouratidis, M. Hadjieleftheriou, and D. Papadias. “Conceptual partitioning: An efficient method for continuous nearest neighbor monitoring,” in Proceedings of ACM SIGMOD, 2005.

  10. M.F. Mokbel, X. Xiong, and W.G. Aref, “SINA: Scalable incremental processing of continuous queries in spatio-temporal databases,” in Proceedings of ACM SIGMOD, 2004.

  11. D. Pfoser, C.S. Jensen, and Y. Theodoridis, “Novel approaches to the indexing of moving object trajectories,” in Proceedings of VLDB, 2000.

  12. N. Roussopoulos, S. Kelley, and F. Vincent. “Nearest neighbor queries,” in Proceedings of ACM SIGMOD, 1995.

  13. S. Saltenis, C.S. Jensen, S. Leutenegger, and M. Lopez. “Indexing the positions of continuously moving objects,” in Proceedings of ACM SIGMOD, 2000.

  14. C. Shahabi, M. Kolahdouzan, and M. Sharifzadeh. “A road network embedding technique for K-nearest neighbor search in moving object databases,” GeoInformatika, Vol. 7(3):255–273, 2003.

    Article  Google Scholar 

  15. Z. Song and N. Roussopoulos. “K-nearest neighbor search for moving query point,” in Proceedings of SSTD, 2001.

  16. Y. Tao and D. Papadias, “Time parameterized queries in spatio-temporal databases,” in Proceedings of ACM SIGMOD, 2002.

  17. Y. Tao, D. Papadias, and Q. Shen. “Continuous nearest neighbor search,” Proceedings of VLDB, 2002.

  18. Y. Theodoridis. “The R-tree portal,” URL: http://www.rtreeportal.org (accessed 13 December 2005).

  19. Y. Theodoridis, J.R.O. Silva, and M.A. Nascimento. “On the generation of spatio-temporal datasets,” in Proceedings of SSD, 1999.

  20. Y. Tao, J. Sun, and D. Papadias. “Analysis of predictive spatio-temporal queries,” ACM Transactions on Database Systems, Vol. 28(4):295–336, 2003 December.

    Article  Google Scholar 

  21. Y. Theodoridis, M. Vazirgiannis, and T. Sellis. “Spatio-temporal indexing for large multimedia applications.” in Proceedings of ICMCS, 1996.

  22. X. Yu, K. Pu, and N. Koudas. “Monitoring k-nearest neighbor queries over moving objects,” in Proceedings of ICDE, 2005.

  23. X. Xiong, M. Mokbel, and W. Aref. “SEA-CNN: Scalable processing of continuous K-nearest neighbor queries in spatio-temporal databases,” in Proceedings of ICDE, 2005.

Download references

Acknowledgements

Research partially supported by the GeoPKDD (“Geographic Privacy-aware Knowledge Discovery and Delivery”) project funded by the European Community under FP6-014915 contract. Research grants by the Archimedes and Pythagoras EPEAEK II Programmes jointly funded by the European Community and the Greek Ministry of National Education and Religious Affairs are also acknowledged. We also thank the anonymous reviewers for providing valuable comments which improved the quality of the paper.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Yannis Theodoridis.

Additional information

This work is an extended version of Frentzos et al., Proceedings of SSTD, pp. 328–345, 2005.

Appendices

Appendix A: Calculation of the minimum “horizontal” distance between two 3D line segments

The Euclidean (“horizontal”) distance function between the projections of two 3D line segments, P and Q, on the 2D (x-,y-) plane is:

$$ {\text{Dist}} = {\sqrt {{\left( {Q_{x} - P_{x} } \right)}^{2} + {\left( {Q_{y} - P_{y} } \right)}^{2} } } $$
(1)

where \( Q_{x} = Q_{{1x}} + {\left( {Q_{{2x}} - Q_{{1x}} } \right)}Δ t \), \( Q_{y} = Q_{{1y}} + {\left( {Q_{{2y}} - Q_{{1y}} } \right)}Δ t \), \( P_{x} = P_{{1x}} + {\left( {P_{{2x}} - P_{{1x}} } \right)}Δ t \) and \( P_{y} = P_{{1y}} + {\left( {P_{{2y}} - P_{{1y}} } \right)}Δ t \). Replacing Q x , Q y , P x , P y in Eq. 1, we get

$$ {\text{Dist}} = {\sqrt {{\left( {Q_{{1x}} + {\left( {Q_{{2x}} - Q_{{1x}} } \right)}\Delta t - P_{{1x}} - {\left( {P_{{2x}} - P_{{1x}} } \right)}\Delta t} \right)}^{2} + {\left( {Q_{{1y}} + {\left( {Q_{{2y}} - Q_{{1y}} } \right)}\Delta t - P_{{1y}} - {\left( {P_{{2y}} - P_{{1y}} } \right)}\Delta t} \right)}^{2} } }. $$

In the sequel, we use the square of the Euclidean distance for sake of readiness.

$$ \begin{array}{*{20}l} {{{\text{Dist}}^{{\text{2}}} = {\left( {Q_{{1x}} + {\left( {Q_{{2x}} - Q_{{1x}} } \right)}\Delta t - P_{{1x}} - {\left( {P_{{2x}} - P_{{1x}} } \right)}\Delta t} \right)}^{2} + {\left( {Q_{{1y}} + {\left( {Q_{{2y}} - Q_{{1y}} } \right)}\Delta t - P_{{1y}} - {\left( {P_{{2y}} - P_{{1y}} } \right)}\Delta t} \right)}^{2} = } \hfill} \\ {{ = {\left( {{\left( {Q_{{2x}} - Q_{{1x}} - P_{{2x}} + P_{{1x}} } \right)}\Delta t + {\left( {Q_{{1x}} - P_{{1x}} } \right)}} \right)}^{2} + {\left( {{\left( {Q_{{2y}} - Q_{{1y}} - P_{{2y}} + P_{{1y}} } \right)}\Delta t + {\left( {Q_{{1y}} - P_{{1y}} } \right)}} \right)}^{2} = } \hfill} \\ {{ = {\left( {{\left( {Q_{{2x}} - Q_{{1x}} - P_{{2x}} + P_{{1x}} } \right)}^{2} + {\left( {Q_{{2y}} - Q_{{1y}} - P_{{2y}} + P_{{1y}} } \right)}^{2} } \right)}\Delta t^{2} + } \hfill} \\ {{ + 2{\left( {{\left( {Q_{{2x}} - Q_{{1x}} - P_{{2x}} + P_{{1x}} } \right)}{\left( {Q_{{1x}} - P_{{1x}} } \right)} + {\left( {Q_{{2y}} - Q_{{1y}} - P_{{2y}} + P_{{1y}} } \right)}{\left( {Q_{{1y}} - P_{{1y}} } \right)}} \right)}\Delta t + {\left( {Q_{{1x}} - P_{{1x}} } \right)}^{2} + {\left( {Q_{{1y}} - P_{{1y}} } \right)}^{2} } \hfill} \\ \end{array} . $$

Setting

$$ A = {\left( {Q_{{2x}} - Q_{{1x}} - P_{{2x}} + P_{{1x}} } \right)}^{2} + {\left( {Q_{{2y}} - Q_{{1y}} - P_{{2y}} + P_{{1y}} } \right)}^{2} $$
(2)
$$ B = 2{\left( {{\left( {Q_{{2x}} - Q_{{1x}} - P_{{2x}} + P_{{1x}} } \right)}{\left( {Q_{{1x}} - P_{{1x}} } \right)} + {\left( {Q_{{2y}} - Q_{{1y}} - P_{{2y}} + P_{{1y}} } \right)}{\left( {Q_{{1y}} - P_{{1y}} } \right)}} \right)} $$
(3)
$$ C = {\left( {Q_{{1x}} - P_{{1x}} } \right)}^{2} + {\left( {Q_{{1y}} - P_{{1y}} } \right)}^{2} $$
(4)

and replacing Δt according to the following formula \( \Delta t = \frac{{t - t_{1} }} {{t_{2} - t_{1} }} \), the Euclidean “horizontal” distance function of two 3D line segments is computed as follows:

$$ {\text{Dist}}^{{\text{2}}} = \frac{A} {{{\left( {t_{2} - t_{1} } \right)}^{2} }}t^{2} + {\left( {\frac{B} {{t_{2} - t_{1} }} - \frac{{2At_{1} }} {{{\left( {t_{2} - t_{1} } \right)}^{2} }}} \right)}t + \frac{{At^{2}_{1} }} {{{\left( {t_{2} - t_{1} } \right)}^{2} }} - \frac{{Bt_{1} }} {{t_{2} - t_{1} }} + C, $$
(5)

where A, B, C are defined by formulas (2), (3), (4), respectively.

As proved before, the square of the Euclidean “horizontal” distance function between two 3D line segments has the quadratic form \( P{\left( t \right)} = At^{2} + Bt + C \), which is minimized at \( P_{{\min }} = C - \frac{{B^{2} }} {{4A}} \) for \( t = - \frac{B} {{2A}} \). Thus, in our case

$$ {\text{Dist}}^{2}_{{\min }} = \frac{{At^{2}_{1} }} {{{\left( {t_{2} - t_{1} } \right)}^{2} }} - \frac{{Bt_{1} }} {{t_{2} - t_{1} }} + C - \frac{{{\left( {\frac{B} {{t_{2} - t_{1} }} - \frac{{2At_{1} }} {{{\left( {t_{2} - t_{1} } \right)}^{2} }}} \right)}^{2} }} {{\frac{{4A}} {{{\left( {t_{2} - t_{1} } \right)}^{2} }}}} $$
(6)

for

$$ t = \frac{{{\left( {\frac{{2At_{1} }} {{{\left( {t_{2} - t_{1} } \right)}^{2} }} - \frac{B} {{t_{2} - t_{1} }}} \right)}}} {{2\frac{A} {{{\left( {t_{2} - t_{1} } \right)}^{2} }}}} $$
(7)

where A, B, C are defined by formulas (2), (3), (4), respectively.

We have to note that formula (6) can be used in case where t calculated by formula (7) is inside the query time period Q per[t start, t end]. Otherwise, we distinguish between the following two cases:

  1. 1.

    if t ≤ t start, then the minimum “horizontal” distance is provided by formula (5) by setting t=t start

  2. 2.

    if t ≥ t end, then the minimum “horizontal” distance is provided by formula (5) by setting t=t end.

Appendix B: Maintaining the Nearests list

The pseudo-code of the UpdateNearests function, which is responsible for the maintenance of the Nearests list, is presented in Figure 26. In particular, the algorithm iterates through the elements of the active Nearests list searching for those elements temporally overlapping the checked entry (CM). When such an element is found, the algorithm applies linear interpolation in both entries (the checked and the one already on the list) producing two new entries having the same temporal extent (M and T). Then, it compares the two distance functions in order to determine whether the entry already on the list is to be replaced or not.

Figure 26
figure 26

UpdateNearests algorithm.

Figure 27 graphically explains all the possible comparisons between the parabolas of two “moving distance” functions.

Figure 27
figure 27

Graphical illustration of UpdateNearests algorithm comparisons.

Figure 27a corresponds to Line 5 of the algorithm presented in Figure 26, where the maximum distance of M is smaller than the minimum of T, leading to the replacement of T with M. Otherwise, after computing the discriminant of the difference between the distance functions of M and T, we have to distinguish among three different cases:

  • The discriminant is less than zero, meaning that the two functions M and T are asymptotic and they do not intersect (Line 9); we only have to check their minimum in order to determine which is the global minimum (see Figure 27b).

  • The discriminant is equal to zero, meaning that the two functions osculate in their common minimum (Line 11); we only have to check their maximum in order to determine the global minimum (see Figure 27c).

  • The discriminant is greater than zero, meaning that the two functions intersect in two points (Line 13). In this case, we have to determine whether these time instances are inside the entry’s lifetime. Hence, we further distinguish among three sub-cases:

    • Both solutions are outside the temporal extent of M (and T) (Line 15). We only have to check their maximum in order to determine which is the globally minimum inside the current temporal interval (see Figure 27d).

    • Both solutions are inside the temporal extent of M (and T) (Line 17). We must break apart the entry into three different entries (see Figure 27e) and determine the part of T to be replaced by M.

    • Only one solution is inside the temporal extent of M (Line 25). We must break apart the entry into two different entries (see Figure 27f) and determine the part of T to be replaced by M.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Frentzos, E., Gratsias, K., Pelekis, N. et al. Algorithms for Nearest Neighbor Search on Moving Object Trajectories. Geoinformatica 11, 159–193 (2007). https://doi.org/10.1007/s10707-006-0007-7

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10707-006-0007-7

Keywords

Navigation