Fixed calculation bug.
This commit is contained in:
@@ -374,7 +374,7 @@ public class Airport {
|
|||||||
*/
|
*/
|
||||||
public double calculateDistance(Airport airport){
|
public double calculateDistance(Airport airport){
|
||||||
double distance = 0;
|
double distance = 0;
|
||||||
double dLong = this.longitude - airport.getLatitude();
|
double dLong = this.longitude - airport.getLongitude();
|
||||||
double dLat = this.latitude - airport.getLatitude();
|
double dLat = this.latitude - airport.getLatitude();
|
||||||
double a = Math.pow((Math.sin(dLat/2)), 2) + Math.cos(this.latitude) * Math.cos(airport.getLatitude()) * Math.pow(Math.sin(dLong/2), 2);
|
double a = Math.pow((Math.sin(dLat/2)), 2) + Math.cos(this.latitude) * Math.cos(airport.getLatitude()) * Math.pow(Math.sin(dLong/2), 2);
|
||||||
double c = a * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
|
double c = a * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
|
||||||
|
|||||||
Reference in New Issue
Block a user