public/scripts.js
//some math I didn't actually think of myself
some math I didn't actually think of myself
some math I didn ' t actually think of myself
function calculateDistance(lat1, lon1, lat2, lon2) {
    var R = 6371e3; 
    var dLat = (lat2 - lat1).toRad();
    var dLon = (lon2 - lon1).toRad(); 
    var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
            Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) * 
            Math.sin(dLon / 2) * Math.sin(dLon / 2); 
    var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); 
    var d = R * c;
    console.log("distance="+d + "R = "+ R);
    return Math.round(d);
    }
function calculateDistance ( lat1 , lon1 , lat2 , lon2 ) { var R = 6371e3 ; var dLat = ( lat2 - lat1 ) . toRad ( ) ; var dLon = ( lon2 - lon1 ) . toRad ( ) ; var a = Math . sin ( dLat / 2 ) * Math . sin ( dLat / 2 ) + Math . cos ( lat1 . toRad ( ) ) * Math . cos ( lat2 . toRad ( ) ) * Math . sin ( dLon / 2 ) * Math . sin ( dLon / 2 ) ; var c = 2 * Math . atan2 ( Math . sqrt ( a ) , Math . sqrt ( 1 - a ) ) ; var d = R * c ; console . log ( "distance=" + d + "R = " + R ) ; return Math . round ( d ) ; }
some math I didn't actually think of myself
some math I didn ' t actually think of myself
// m