Hi, I need to measure the distance between two locations (GPS coordinates)

I found the the following math here: math - Calculate distance between 2 GPS coordinates - Stack Overflow

```
function degreesToRadians(degrees) {
return degrees * Math.PI / 180;
}
function distanceInKmBetweenEarthCoordinates(lat1, lon1, lat2, lon2) {
var earthRadiusKm = 6371;
var dLat = degreesToRadians(lat2-lat1);
var dLon = degreesToRadians(lon2-lon1);
lat1 = degreesToRadians(lat1);
lat2 = degreesToRadians(lat2);
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
return earthRadiusKm * c;
}
```

And I â€śimportedâ€ť the idea to Kodular as follow:

But when I run, the distance does not match.

I tested the suggested values for lat/long,lat1/long1 and also other coordinates but no good.

I checked the math a number of times and cannot find where I did wrong.

I did create a variable â€śbâ€ť just to make the blocks more readable but it does not change the result.

Help welcome

Thanks in advance

Paulo