Postgre SQL function to calculate distance between two geographical points