Example #1
0
 public function equals(Coordinate $otherCoord)
 {
     if ($otherCoord->getLatitude() == $this->latitude && $otherCoord->getLongitude() == $this->longitude) {
         return true;
     }
     return false;
 }
Example #2
0
 /**
  * @param Coordinate $coordinate
  * @param array      $distanceUnit
  *
  * @return float
  */
 public function distanceFrom(Coordinate $coordinate, array $distanceUnit = null)
 {
     if ($distanceUnit === null) {
         $distanceUnit = DistanceUnit::KM;
     }
     $theta = $this->getLongitude()->toNative() - $coordinate->getLongitude()->toNative();
     $dist = sin(deg2rad($this->getLatitude()->toNative())) * sin(deg2rad($coordinate->getLatitude()->toNative())) + cos(deg2rad($this->getLatitude()->toNative())) * cos(deg2rad($coordinate->getLatitude()->toNative())) * cos(deg2rad($theta));
     $dist = acos($dist);
     $dist = rad2deg($dist);
     $unit = $dist * 60 * $distanceUnit;
     return round($unit, 1);
 }
Example #3
0
 /**
  * @param Coordinate $otherCoordinate
  * @return bool
  */
 public function equals(Coordinate $otherCoordinate)
 {
     return $otherCoordinate->getLatitude() == $this->latitude && $otherCoordinate->getLongitude() == $this->longitude;
 }