Correction de : Distance renvoie NaN si les deux points sont égaux. (fix non testé)

This commit is contained in:
Didier Le Botlan 2022-04-12 19:42:23 +02:00
parent dd5ed04891
commit ce5c34cb06

View File

@ -25,7 +25,15 @@ public final class Point {
double cosLat = Math.cos(Math.toRadians(p1.getLatitude())) double cosLat = Math.cos(Math.toRadians(p1.getLatitude()))
* Math.cos(Math.toRadians(p2.getLatitude())); * Math.cos(Math.toRadians(p2.getLatitude()));
double cosLong = Math.cos(Math.toRadians(p2.getLongitude() - p1.getLongitude())); double cosLong = Math.cos(Math.toRadians(p2.getLongitude() - p1.getLongitude()));
return EARTH_RADIUS * Math.acos(sinLat + cosLat * cosLong);
double koef = sinLat + cosLat * cosLong ;
if (koef >= 1.0) { koef = 1.0 ; }
if (koef <= -1.0) { koef = -1.0 ; }
res = EARTH_RADIUS * Math.acos(koef) ;
return res
} }
// Longitude and latitude of the point. // Longitude and latitude of the point.