Example #1
0
 /**
  * testCalculateDestinationForBearingAndDistanceReturnsExpectedValue
  *
  * @param LatLong $latLong The starting point.
  * @param float $bearing The initial bearing.
  * @param float $distance The distance in metres to travel.
  * @param LatLong $expected The expected destination.
  *
  * @dataProvider getLatLongWithInitialBearingDistanceAndDestination
  */
 public function testCalculateDestinationForBearingAndDistanceReturnsExpectedValue(LatLong $latLong, $bearing, $distance, LatLong $expected)
 {
     $actual = $latLong->calculateDestinationForBearingAndDistance($bearing, $distance);
     $tolerance = 0.3;
     $this->assertEqualsWithinTolerance($expected->getLatitude(), $actual->getLatitude(), $tolerance);
     $this->assertEqualsWithinTolerance($expected->getLongitude(), $actual->getLongitude(), $tolerance);
     $this->assertEquals($latLong->getHeight(), $actual->getHeight());
     // Height remains constant.
     $this->assertEquals($expected->getDatum(), $actual->getDatum());
 }
Example #2
0
 /**
  * Calculate the final bearing to follow from this point to arrive at the given destination.
  *
  * @param LatLong $destination The destination.
  *
  * @return float The bearing in decimal degrees.
  */
 public function calculateFinalBearing(LatLong $destination)
 {
     $initialBearing = $destination->calculateInitialBearing($this);
     return fmod($initialBearing + 180, 360);
 }