public function equals(Coordinate $otherCoord) { if ($otherCoord->getLatitude() == $this->latitude && $otherCoord->getLongitude() == $this->longitude) { return true; } return false; }
/** * @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); }
/** * @param Coordinate $otherCoordinate * @return bool */ public function equals(Coordinate $otherCoordinate) { return $otherCoordinate->getLatitude() == $this->latitude && $otherCoordinate->getLongitude() == $this->longitude; }