Optimization in Educational
Optimize the calculation of the closest point on the route.
Make use of the bounding box of each route segment as a quick estimate
of the minimum distance to a given point (current location). Cache the
last visited segment as an educated guess for the segment with the
smallest distance. Only calculate the distance to all points of a
segment if its minimal distance is smaller than the guessed minimum
distance. In the average case only one segment has to be fully
evaluated to determine the smallest distance.
Reduces the cpu consumption by about 9% (callgrind, large routes).