Calculating 3D ground distance and total elevation gain