Actually, I think the correct formula is sqrt(|x1 - x2|^2 + |y1 - y2|^2), i.e.,

Code:const double latitude_dist = p1.latitude - p2.latitude; const double longitude_dist = p1.longitude - p2.longitude; distance = sqrt(latitude_dist * latitude_dist + longitude_dist * longitude_dist);