MySQL function for calculating distance between two locations