Adding a new function to find the location of the nearest edge.