If your arrays are sorted, you can use a binary search to find the position of the requested point in the array. After you find the index, you must check four nearby points to find the nearest one.
1) Suppose you have two sorted arrays of longitude - wise and latitudinal -
2) First, you search and find two adjacent points.
3) Then you search for the second and find two more points
4) Now you have two to four points (results may overlap)
5) These points form a square around the destination
6) Find the nearest point
source share