fixed distance function for different projection type