Calculation of distance and bearing