I want to calculate the distance between two locations with their coordinates. I have seen this question and it has implementations in different languages. Since I'm a beginner in prolog, it would be really helpful if anyone can build a prolog clause that can do such operation.
I've found this python function simpler:
from math import cos, asin, sqrt
def distance(lat1, lon1, lat2, lon2):
p = 0.017453292519943295
a = 0.5 - cos((lat2 - lat1) * p)/2 + cos(lat1 * p) * cos(lat2 * p) * (1 - cos((lon2 - lon1) * p)) / 2
return 12742 * asin(sqrt(a))