Location.php
public function distance(Location $otherLocation)
    {
        $theta = $this->longitude - $otherLocation->getLongitude();
        $distance = (sin(deg2rad($this->latitude))
            * sin(deg2rad($otherLocation->getLatitude())))
            + (cos(deg2rad($this->latitude))
            * cos(deg2rad($otherLocation->getLatitude()))
            * cos(deg2rad($theta)));
        $distance = acos($distance);
        $distance = rad2deg($distance);

        return (float) $distance * 60 * 1.1515;
    }
public function distance(Location $otherLocation)
    {
        $theta = $this->longitude - $otherLocation->getLongitude();
        $distance = (sin(deg2rad($this->latitude))
            * sin(deg2rad($otherLocation->getLatitude())))
            + (cos(deg2rad($this->latitude))
            * cos(deg2rad($otherLocation->getLatitude()))
            * cos(deg2rad($theta)));
        $distance = acos($distance);
        $distance = rad2deg($distance);

        return (float) $distance * 60 * 1.1515;
    }
public function distance ( Location $ otherLocation ) { $ theta = $ this -> longitude - $ otherLocation -> getLongitude ( ) ; $ distance = ( sin ( deg2rad ( $ this -> latitude ) ) * sin ( deg2rad ( $ otherLocation -> getLatitude ( ) ) ) ) + ( cos ( deg2rad ( $ this -> latitude ) ) * cos ( deg2rad ( $ otherLocation -> getLatitude ( ) ) ) * cos ( deg2rad ( $ theta ) ) ) ; $ distance = acos ( $ distance ) ; $ distance = rad2deg ( $ distance ) ; return ( float ) $ distance * 60 * 1.1515 ; }
Get the distance between the Location and a given Location.

@param Location $otherLocation

@return float
Get the distance between the Location and a given Location .