public function exactDistanceFrom(LatLng $coord)
    {
        $lat1 = deg2rad($this->getLat());
        $lat2 = deg2rad($coord->getLat());
        $lon1 = deg2rad($this->getLng());
        $lon2 = deg2rad($coord->getLng());

        $dLatHalf = ($lat2 - $lat1) / 2;
        $dLonHalf = ($lon2 - $lon1) / 2;

        $a = pow(sin($dLatHalf), 2) + cos($lat1) * cos($lat2) * pow(sin($dLonHalf), 2);
        $c = 2 * atan2(sqrt($a), sqrt(1 - $a));

        return $c * UnitsType::EARTH_RADIUS;
    }
public function exactDistanceFrom(LatLng $coord)
    {
        $lat1 = deg2rad($this->getLat());
        $lat2 = deg2rad($coord->getLat());
        $lon1 = deg2rad($this->getLng());
        $lon2 = deg2rad($coord->getLng());

        $dLatHalf = ($lat2 - $lat1) / 2;
        $dLonHalf = ($lon2 - $lon1) / 2;

        $a = pow(sin($dLatHalf), 2) + cos($lat1) * cos($lat2) * pow(sin($dLonHalf), 2);
        $c = 2 * atan2(sqrt($a), sqrt(1 - $a));

        return $c * UnitsType::EARTH_RADIUS;
    }
public function exactDistanceFrom ( LatLng $ coord ) { $ lat1 = deg2rad ( $ this -> getLat ( ) ) ; $ lat2 = deg2rad ( $ coord -> getLat ( ) ) ; $ lon1 = deg2rad ( $ this -> getLng ( ) ) ; $ lon2 = deg2rad ( $ coord -> getLng ( ) ) ; $ dLatHalf = ( $ lat2 - $ lat1 ) / 2 ; $ dLonHalf = ( $ lon2 - $ lon1 ) / 2 ; $ a = pow ( sin ( $ dLatHalf ) , 2 ) + cos ( $ lat1 ) * cos ( $ lat2 ) * pow ( sin ( $ dLonHalf ) , 2 ) ; $ c = 2 * atan2 ( sqrt ( $ a ) , sqrt ( 1 - $ a ) ) ; return $ c * UnitsType :: EARTH_RADIUS ; }
Exact distance with Haversine formula

@param LatLng $coord

@return float
@see http://www.movable-type.co.uk/scripts/latlong.html
Exact distance with Haversine formula