<?php

//require("includes/check_auth_user.php");
//require("includes/dbconnect.php");
//include ('includes/function.php');
//
//$zdb = $_SESSION["zdbyear_" . $dbname];
//mysqli_select_db($conn, $zdb);
//$admin = $_SESSION["admin_" . $dbname];
//$success = false;

function getDistance($latitude1, $longitude1, $latitude2, $longitude2) {
    $earthRadius = 6371;
    echo $earthRadius;
    $latFrom = deg2grad($latitude1);
    echo $latFrom;
    $longFrom = deg2grad($longitude1);
    echo $longFrom;
    $latTo = deg2grad($latitude2);
    echo $latTo;
    $longTo = deg2grad($longitude2);
    echo $longTo;
    
    $latDelta = $latTo - $latFrom;
    $lonDelta = $longTo - $longFrom;

    $angle = 2 * asin(sqrt(pow(sin($latDelta / 2), 2) + cos($latFrom) * cos($latTo) * pow(sin($lonDelta / 2), 2)));
    return $angle * $earthRadius;
}

$latitude1 = 19.075983;
$longitude1 = 72.877655;

$latitude2 = 18.520430;
$longitude2 = 73.856743;
//browse($latitude1);
//    browse($latitude2);

$distance = getDistance($latitude1, $longitude1, $latitude2, $longitude2);
browse('1');
echo $distance;

// Distance from New York to London
//echo lat_long_dist_of_two_points(19.0760, 72.8777, 18.5204, 73.8567) . ' mi' . "\n";
?>