-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added Hubeny, Andoyer-Lambert and Thomas Formulas. Fixed Vincenty.
- Loading branch information
Showing
14 changed files
with
228 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Geodesy\Distance; | ||
|
||
use Geodesy\Location\LatLong; | ||
|
||
class AndoyerLambert extends BaseDistance implements DistanceInterface | ||
{ | ||
|
||
|
||
public function __construct(LatLong $source, LatLong $destination) | ||
{ | ||
parent::__construct($source, $destination); | ||
} | ||
|
||
|
||
public function distance() | ||
{ | ||
$lat1 = deg2rad($this->source->getLatitude()); | ||
$lat2 = deg2rad($this->destination->getLatitude()); | ||
$long1 = deg2rad($this->source->getLongitude()); | ||
$long2 = deg2rad($this->destination->getLongitude()); | ||
$a = $this->constants::A; | ||
$b = $this->constants::B; | ||
$f = $this->constants::F; | ||
$long_diff = $long2 - $long1; | ||
$rLat1=atan($b*tan($lat1)/$a); | ||
$rLat2=atan($b*tan($lat2)/$a); | ||
$spherical_distance = acos(sin($rLat1) * sin($rLat2) + cos($rLat1) * cos($rLat2) * cos($long_diff)); | ||
$cosineSd = cos($spherical_distance/2.0); | ||
$sinSd = sin($spherical_distance/2.0); | ||
$c = (sin($spherical_distance) - $spherical_distance) * (sin($rLat1)+sin($rLat2))*(sin($rLat1)+sin($rLat2)) / pow($cosineSd, 2); | ||
$s = (sin($spherical_distance) + $spherical_distance) * (sin($rLat1)-sin($rLat2))*(sin($rLat1)-sin($rLat2)) / pow($sinSd,2); | ||
$delta = $f / 8.0 * ($c-$s); | ||
|
||
return $a*($spherical_distance+$delta); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Geodesy\Distance; | ||
|
||
use Geodesy\Location\LatLong; | ||
|
||
class HubenyFormula extends BaseDistance implements DistanceInterface | ||
{ | ||
|
||
|
||
public function __construct(LatLong $source, LatLong $destination) | ||
{ | ||
parent::__construct($source, $destination); | ||
} | ||
|
||
|
||
public function distance() | ||
{ | ||
$lat1 = deg2rad($this->source->getLatitude()); | ||
$lat2 = deg2rad($this->destination->getLatitude()); | ||
$long1 = deg2rad($this->source->getLongitude()); | ||
$long2 = deg2rad($this->destination->getLongitude()); | ||
$a = $this->constants::A; | ||
$b = $this->constants::B; | ||
$f = $this->constants::F; | ||
$f2 = ($b * $b) / ($a * $a); | ||
$e2 = 1.0 - $f2; | ||
|
||
$lat_diff = ($lat1 - $lat2); | ||
$long_diff = ($long1 - $long2); | ||
$lat_average = 0.5 * ($lat1 + $lat2); | ||
$sinlat_average = sin($lat_average); | ||
$coslat_average = cos($lat_average); | ||
$w2 = 1.0 - $sinlat_average * $sinlat_average * $e2; | ||
$w = sqrt($w2); | ||
$meridian = $a * $f2 / ($w2 * $w); | ||
$n = $a / $w; | ||
|
||
return sqrt( | ||
$lat_diff * $lat_diff * $meridian * $meridian + | ||
$long_diff * $long_diff * $n * $n * $coslat_average * $coslat_average | ||
); | ||
|
||
|
||
return $a*($spherical_distance+$delta); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace Geodesy\Distance; | ||
|
||
use Geodesy\Location\LatLong; | ||
|
||
class ThomasFormula extends BaseDistance implements DistanceInterface | ||
{ | ||
|
||
|
||
public function __construct(LatLong $source, LatLong $destination) | ||
{ | ||
parent::__construct($source, $destination); | ||
} | ||
|
||
|
||
public function distance() | ||
{ | ||
|
||
$A = $this->constants::A; | ||
$F = $this->constants::F; | ||
$ac = deg2rad($this->source->getLatitude()); | ||
$ad = -deg2rad($this->source->getLongitude()); | ||
$ac = atan((1.0-$F) * tan($ac)); | ||
|
||
$ae = deg2rad($this->destination->getLatitude()); | ||
$af = -deg2rad($this->destination->getLongitude()); | ||
$ae = atan((1.0-$F) * tan($ae)); | ||
|
||
|
||
$i = $af - $ad; | ||
$j = ($ae + $ac) / 2.0; | ||
$ak = ($ae - $ac) / 2.0; | ||
$h = cos($ak) * cos($ak) - sin($j) * sin($j); | ||
|
||
$l = sin($ak) * sin($ak) + $h * sin($i/2.0) * sin($i/2.0); | ||
$d = 2.0 * atan(sqrt($l/(1.0-$l))); | ||
|
||
$u = 2.0 * sin($j) * sin($j) * cos($ak) * cos($ak) / (1.0 - $l); | ||
$v = 2.0 * sin($ak) * sin($ak) * cos($j) * cos($j) / $l; | ||
|
||
$x = $u + $v; | ||
$y = $u - $v; | ||
$t = $d / sin($d); | ||
$dd = 4.0 * $t * $t; | ||
$e =2.0 * cos($d); | ||
$a = $dd * $e; | ||
|
||
$c = $t - ($a - $e) / 2.0; | ||
$n1 = $x * ($a + $c * $x); | ||
$b = 2.0 * $dd; | ||
$n2 = $y * ($b + $e * $y); | ||
$n3 = $dd * $x * $y; | ||
|
||
$d1d=$F * ($t * $x - $y)/4.0; | ||
$d2d=$F * $F * ($n1 - $n2 + $n3)/64.0; | ||
|
||
return $A * ($t - $d1d + $d2d) * sin($d); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.