Treffynnon\Navigator\Distance\Calculator\GreatCircle::calculate PHP Method

calculate() public method

Supply instances of the coordinate class. http://www.ga.gov.au/earth-monitoring/geodesy/geodetic-techniques/distance-calculation-algorithms.html#circle
public calculate ( Treffynnon\Navigator\LatLong $point1, Treffynnon\Navigator\LatLong $point2 ) : float
$point1 Treffynnon\Navigator\LatLong
$point2 Treffynnon\Navigator\LatLong
return float
    public function calculate(N\LatLong $point1, N\LatLong $point2)
    {
        $celestialBody = $this->getCelestialBody();
        $degrees = acos(sin($point1->getLatitude()->get()) * sin($point2->getLatitude()->get()) + cos($point1->getLatitude()->get()) * cos($point2->getLatitude()->get()) * cos($point2->getLongitude()->get() - $point1->getLongitude()->get()));
        $d = $degrees * $celestialBody->volumetricMeanRadius;
        return $d * 1000;
    }

Usage Example

Esempio n. 1
0
 public function testCalculate()
 {
     $GreatCircle = new C\GreatCircle();
     $point1 = new N\LatLong(new N\Coordinate(80.90000000000001), new N\Coordinate(20.1));
     $point2 = new N\LatLong(new N\Coordinate(20.1), new N\Coordinate(80.90000000000001));
     $metres = $GreatCircle->calculate($point1, $point2);
     $this->assertEquals(7303552.8457791, $metres, '', 0.2);
 }
All Usage Examples Of Treffynnon\Navigator\Distance\Calculator\GreatCircle::calculate
GreatCircle