/** * Calculate the spherical distance from current coordinate to a other one. * * @param \Beluga\GIS\Coordinate $otherPoint * @return integer */ public function calcSphericalDistanceTo(Coordinate $otherPoint) { if (!$this->isValid()) { return 0; } $b1 = $this->Latitude->getDecimalValue(); $l1 = $this->Longitude->getDecimalValue(); $b2 = $otherPoint->Latitude->getDecimalValue(); $l2 = $otherPoint->Longitude->getDecimalValue(); $rbreite1 = $b1 * self::DEG2RAD; $rlaenge1 = $l1 * self::DEG2RAD; $rbreite2 = $b2 * self::DEG2RAD; $rlaenge2 = $l2 * self::DEG2RAD; $rwinkel = \acos(\sin($rbreite1) * \sin($rbreite2) + \cos($rbreite1) * \cos($rbreite2) * \cos(\abs($rlaenge2 - $rlaenge1))); $entfernung = $rwinkel * 6370; return \round($entfernung, 3); }