Skip to content

Commit

Permalink
Merge 0c22ea9 into 3ba562c
Browse files Browse the repository at this point in the history
  • Loading branch information
mjaschen committed Mar 22, 2019
2 parents 3ba562c + 0c22ea9 commit d8e9779
Show file tree
Hide file tree
Showing 29 changed files with 87 additions and 361 deletions.
46 changes: 18 additions & 28 deletions src/Bearing/BearingEllipsoidal.php
@@ -1,41 +1,31 @@
<?php
declare(strict_types=1);

/**
* Calculation of bearing between two points using a
* ellipsoidal model of the earth
*
* This class is based on the awesome work Chris Veness
* has done. For more information visit the following URL.
*
* @see http://www.movable-type.co.uk/scripts/latlong-vincenty.html
*
* @author Marcus Jaschen <mjaschen@gmail.com>
* @license https://opensource.org/licenses/MIT
* @link https://github.com/mjaschen/phpgeo
*/

namespace Location\Bearing;

use InvalidArgumentException;
use Location\Coordinate;
use Location\Exception\NotConvergingException;

/**
* Calculation of bearing between two points using a
* ellipsoidal model of the earth
* ellipsoidal model of the earth.
*
* @author Marcus Jaschen <mjaschen@gmail.com>
* @license https://opensource.org/licenses/MIT
* @link https://github.com/mjaschen/phpgeo
* This class is based on the awesome work Chris Veness
* has done. For more information visit the following URL.
*
* @see http://www.movable-type.co.uk/scripts/latlong-vincenty.html
*
* @author Marcus Jaschen <mjaschen@gmail.com>
*/
class BearingEllipsoidal implements BearingInterface
{
/**
* This method calculates the initial bearing between the
* two points.
*
* @param \Location\Coordinate $point1
* @param \Location\Coordinate $point2
* @param Coordinate $point1
* @param Coordinate $point2
*
* @return float Bearing Angle
*/
Expand All @@ -47,8 +37,8 @@ public function calculateBearing(Coordinate $point1, Coordinate $point2): float
/**
* Calculates the final bearing between the two points.
*
* @param \Location\Coordinate $point1
* @param \Location\Coordinate $point2
* @param Coordinate $point1
* @param Coordinate $point2
*
* @return float
*/
Expand All @@ -61,7 +51,7 @@ public function calculateFinalBearing(Coordinate $point1, Coordinate $point2): f
* Calculates a destination point for the given point, bearing angle,
* and distance.
*
* @param \Location\Coordinate $point
* @param Coordinate $point
* @param float $bearing the bearing angle between 0 and 360 degrees
* @param float $distance the distance to the destination point in meters
*
Expand All @@ -77,13 +67,13 @@ public function calculateDestination(Coordinate $point, float $bearing, float $d
* The method expects a starting point point, the bearing angle,
* and the distance to destination.
*
* @param \Location\Coordinate $point
* @param Coordinate $point
* @param float $bearing
* @param float $distance
*
* @return float
*
* @throws \Location\Exception\NotConvergingException
* @throws NotConvergingException
*/
public function calculateDestinationFinalBearing(Coordinate $point, float $bearing, float $distance): float
{
Expand All @@ -97,8 +87,8 @@ public function calculateDestinationFinalBearing(Coordinate $point, float $beari
*
* @return DirectVincentyBearing
*
* @throws \Location\Exception\NotConvergingException
* @throws \InvalidArgumentException
* @throws NotConvergingException
* @throws InvalidArgumentException
*/
private function directVincenty(Coordinate $point, float $bearing, float $distance): DirectVincentyBearing
{
Expand Down Expand Up @@ -162,7 +152,7 @@ private function directVincenty(Coordinate $point, float $bearing, float $distan
*
* @return InverseVincentyBearing
*
* @throws \Location\Exception\NotConvergingException
* @throws NotConvergingException
*/
private function inverseVincenty(Coordinate $point1, Coordinate $point2): InverseVincentyBearing
{
Expand Down
15 changes: 10 additions & 5 deletions src/Bearing/BearingInterface.php
Expand Up @@ -5,14 +5,19 @@

use Location\Coordinate;

/**
* Interface BearingInterface
*
* @author Marcus Jaschen <mjaschen@gmail.com>
*/
interface BearingInterface
{
/**
* This method calculates the initial bearing between the
* two points.
*
* @param \Location\Coordinate $point1
* @param \Location\Coordinate $point2
* @param Coordinate $point1
* @param Coordinate $point2
*
* @return float Bearing Angle
*/
Expand All @@ -21,8 +26,8 @@ public function calculateBearing(Coordinate $point1, Coordinate $point2): float;
/**
* Calculates the final bearing between the two points.
*
* @param \Location\Coordinate $point1
* @param \Location\Coordinate $point2
* @param Coordinate $point1
* @param Coordinate $point2
*
* @return float
*/
Expand All @@ -32,7 +37,7 @@ public function calculateFinalBearing(Coordinate $point1, Coordinate $point2): f
* Calculates a destination point for the given point, bearing angle,
* and distance.
*
* @param \Location\Coordinate $point
* @param Coordinate $point
* @param float $bearing the bearing angle between 0 and 360 degrees
* @param float $distance the distance to the destination point in meters
*
Expand Down
26 changes: 8 additions & 18 deletions src/Bearing/BearingSpherical.php
@@ -1,26 +1,16 @@
<?php
declare(strict_types=1);

/**
* Calculation of bearing between two points using a
* simple spherical model of the earth.
*
* @author Marcus Jaschen <mjaschen@gmail.com>
* @license https://opensource.org/licenses/MIT
* @link https://github.com/mjaschen/phpgeo
*/

namespace Location\Bearing;

use InvalidArgumentException;
use Location\Coordinate;

/**
* Calculation of bearing between two points using a
* simple spherical model of the earth.
*
* @author Marcus Jaschen <mjaschen@gmail.com>
* @license https://opensource.org/licenses/MIT
* @link https://github.com/mjaschen/phpgeo
* @author Marcus Jaschen <mjaschen@gmail.com>
*/
class BearingSpherical implements BearingInterface
{
Expand All @@ -33,8 +23,8 @@ class BearingSpherical implements BearingInterface
* This method calculates the initial bearing between the
* two points.
*
* @param \Location\Coordinate $point1
* @param \Location\Coordinate $point2
* @param Coordinate $point1
* @param Coordinate $point2
*
* @return float Bearing Angle
*/
Expand All @@ -60,8 +50,8 @@ public function calculateBearing(Coordinate $point1, Coordinate $point2): float
/**
* Calculates the final bearing between the two points.
*
* @param \Location\Coordinate $point1
* @param \Location\Coordinate $point2
* @param Coordinate $point1
* @param Coordinate $point2
*
* @return float
*/
Expand All @@ -76,12 +66,12 @@ public function calculateFinalBearing(Coordinate $point1, Coordinate $point2): f
* Calculates a destination point for the given point, bearing angle,
* and distance.
*
* @param \Location\Coordinate $point
* @param Coordinate $point
* @param float $bearing the bearing angle between 0 and 360 degrees
* @param float $distance the distance to the destination point in meters
*
* @return Coordinate
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*/
public function calculateDestination(Coordinate $point, float $bearing, float $distance): Coordinate
{
Expand Down
12 changes: 1 addition & 11 deletions src/Bearing/DirectVincentyBearing.php
@@ -1,24 +1,14 @@
<?php
declare(strict_types=1);

/**
* Value object for a "Direct Vincenty" bearing calculation result.
*
* @author Marcus Jaschen <mjaschen@gmail.com>
* @license https://opensource.org/licenses/MIT
* @link https://github.com/mjaschen/phpgeo
*/

namespace Location\Bearing;

use Location\Coordinate;

/**
* Value object for a "Direct Vincenty" bearing calculation result.
*
* @author Marcus Jaschen <mjaschen@gmail.com>
* @license https://opensource.org/licenses/MIT
* @link https://github.com/mjaschen/phpgeo
* @author Marcus Jaschen <mjaschen@gmail.com>
*/
class DirectVincentyBearing
{
Expand Down
12 changes: 1 addition & 11 deletions src/Bearing/InverseVincentyBearing.php
@@ -1,22 +1,12 @@
<?php
declare(strict_types=1);

/**
* Value object for a "Inverse Vincenty" bearing calculation result.
*
* @author Marcus Jaschen <mjaschen@gmail.com>
* @license https://opensource.org/licenses/MIT
* @link https://github.com/mjaschen/phpgeo
*/

namespace Location\Bearing;

/**
* Value object for a "Direct Vincenty" bearing calculation result.
*
* @author Marcus Jaschen <mjaschen@gmail.com>
* @license https://opensource.org/licenses/MIT
* @link https://github.com/mjaschen/phpgeo
* @author Marcus Jaschen <mjaschen@gmail.com>
*/
class InverseVincentyBearing
{
Expand Down
4 changes: 1 addition & 3 deletions src/Bounds.php
Expand Up @@ -6,9 +6,7 @@
/**
* Coordinate Bounds Class
*
* @author Marcus Jaschen <mjaschen@gmail.com>
* @license https://opensource.org/licenses/MIT
* @link https://github.com/mjaschen/phpgeo
* @author Marcus Jaschen <mjaschen@gmail.com>
*/
class Bounds
{
Expand Down
12 changes: 1 addition & 11 deletions src/Coordinate.php
@@ -1,14 +1,6 @@
<?php
declare(strict_types=1);

/**
* Coordinate Implementation
*
* @author Marcus Jaschen <mjaschen@gmail.com>
* @license https://opensource.org/licenses/MIT
* @link https://github.com/mjaschen/phpgeo
*/

namespace Location;

use Location\Distance\DistanceInterface;
Expand All @@ -17,9 +9,7 @@
/**
* Coordinate Implementation
*
* @author Marcus Jaschen <mjaschen@gmail.com>
* @license https://opensource.org/licenses/MIT
* @link https://github.com/mjaschen/phpgeo
* @author Marcus Jaschen <mjaschen@gmail.com>
*/
class Coordinate implements GeometryInterface
{
Expand Down
12 changes: 1 addition & 11 deletions src/Distance/DistanceInterface.php
@@ -1,24 +1,14 @@
<?php
declare(strict_types=1);

/**
* Interface for Distance Calculator Classes
*
* @author Marcus Jaschen <mjaschen@gmail.com>
* @license https://opensource.org/licenses/MIT
* @link https://github.com/mjaschen/phpgeo
*/

namespace Location\Distance;

use Location\Coordinate;

/**
* Interface for Distance Calculator Classes
*
* @author Marcus Jaschen <mjaschen@gmail.com>
* @license https://opensource.org/licenses/MIT
* @link https://github.com/mjaschen/phpgeo
* @author Marcus Jaschen <mjaschen@gmail.com>
*/
interface DistanceInterface
{
Expand Down
16 changes: 3 additions & 13 deletions src/Distance/Haversine.php
@@ -1,14 +1,6 @@
<?php
declare(strict_types=1);

/**
* Implementation of distance calculation with http://en.wikipedia.org/wiki/Law_of_haversines
*
* @author Marcus Jaschen <mjaschen@gmail.com>
* @license https://opensource.org/licenses/MIT
* @link https://github.com/mjaschen/phpgeo
*/

namespace Location\Distance;

use Location\Coordinate;
Expand All @@ -18,11 +10,9 @@
/**
* Implementation of distance calculation with http://en.wikipedia.org/wiki/Law_of_haversines
*
* @see http://en.wikipedia.org/wiki/Law_of_haversines
* @see http://en.wikipedia.org/wiki/Law_of_haversines
*
* @author Marcus Jaschen <mjaschen@gmail.com>
* @license https://opensource.org/licenses/MIT
* @link https://github.com/mjaschen/phpgeo
* @author Marcus Jaschen <mjaschen@gmail.com>
*/
class Haversine implements DistanceInterface
{
Expand All @@ -36,7 +26,7 @@ class Haversine implements DistanceInterface
*/
public function getDistance(Coordinate $point1, Coordinate $point2): float
{
if ($point1->getEllipsoid() != $point2->getEllipsoid()) {
if ($point1->getEllipsoid()->getName() !== $point2->getEllipsoid()->getName()) {
throw new NotMatchingEllipsoidException('The ellipsoids for both coordinates must match');
}

Expand Down
14 changes: 2 additions & 12 deletions src/Distance/Vincenty.php
@@ -1,14 +1,6 @@
<?php
declare(strict_types=1);

/**
* Implementation of distance calculation with Vincenty Method
*
* @author Marcus Jaschen <mjaschen@gmail.com>
* @license https://opensource.org/licenses/MIT
* @link https://github.com/mjaschen/phpgeo
*/

namespace Location\Distance;

use Location\Coordinate;
Expand All @@ -18,11 +10,9 @@
/**
* Implementation of distance calculation with Vincenty Method
*
* @see http://www.movable-type.co.uk/scripts/latlong-vincenty.html
* @see http://www.movable-type.co.uk/scripts/latlong-vincenty.html
*
* @author Marcus Jaschen <mjaschen@gmail.com>
* @license https://opensource.org/licenses/MIT
* @link https://github.com/mjaschen/phpgeo
* @author Marcus Jaschen <mjaschen@gmail.com>
*/
class Vincenty implements DistanceInterface
{
Expand Down

0 comments on commit d8e9779

Please sign in to comment.