Not going to work when your next position is only 50 feet away. So I wrote the simple SQL function below based directly on Seth Longâs version here. Now, since Iâm storing positional latitude, longitude and intersection information in my database, itâs simple to just calculate the numbers.