Open seehat opened 2 years ago
The two points I tried to calculate the distance are completely the same and I get NAN as a result and expect 0:
object(Kirby\Geo\Point)#908 (2) { ["lat":protected]=> float(48.70064064733967512665913091041147708892822265625) ["lng":protected]=> float(16.803304953509563546276694978587329387664794921875) } object(Kirby\Geo\Point)#908 (2) { ["lat":protected]=> float(48.70064064733967512665913091041147708892822265625) ["lng":protected]=> float(16.803304953509563546276694978587329387664794921875) }
The result of acos($dist) in Geo.php in the distance method becomes NAN, because $dist is greater than 1. I added a rounding to 14 decimal places with $dist = round($dist, 14);
acos($dist)
$dist = round($dist, 14);
Is there a cleaner way for this?
I think this case of the same point can be hardcoded by checking if both lat and lng are the same. If so, return 0.
lat
lng
0
The two points I tried to calculate the distance are completely the same and I get NAN as a result and expect 0:
The result of
acos($dist)
in Geo.php in the distance method becomes NAN, because $dist is greater than 1. I added a rounding to 14 decimal places with$dist = round($dist, 14);
Is there a cleaner way for this?