Adding functions to get the distance to the nearest edge.