petite modif let

This commit is contained in:
Thomas Cardon 2022-02-15 15:00:40 +01:00
parent 993be2e1b0
commit 1726ec44b2
1 changed files with 6 additions and 6 deletions

View File

@ -32,16 +32,16 @@ export class CardRestoComponent implements OnInit {
} }
getDistanceFromLatLonInKm(lat1 : number , lon1 : number, lat2 : number, lon2 : number) { getDistanceFromLatLonInKm(lat1 : number , lon1 : number, lat2 : number, lon2 : number) {
var R = 6371; // Radius of the earth in km let R = 6371; // Radius of the earth in km
var dLat = this.deg2rad(lat2-lat1); // deg2rad below let dLat = this.deg2rad(lat2-lat1); // deg2rad below
var dLon = this.deg2rad(lon2-lon1); let dLon = this.deg2rad(lon2-lon1);
var a = let a =
Math.sin(dLat/2) * Math.sin(dLat/2) + Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(this.deg2rad(lat1)) * Math.cos(this.deg2rad(lat2)) * Math.cos(this.deg2rad(lat1)) * Math.cos(this.deg2rad(lat2)) *
Math.sin(dLon/2) * Math.sin(dLon/2) Math.sin(dLon/2) * Math.sin(dLon/2)
; ;
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); let c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d = R * c * 1000; // Distance in meters let d = R * c * 1000; // Distance in meters
return d; return d;
} }