Algorithms for analyzing collections of trajectories