1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* PHPCoord. |
4
|
|
|
* |
5
|
|
|
* @author Doug Wright |
6
|
|
|
*/ |
7
|
|
|
declare(strict_types=1); |
8
|
|
|
|
9
|
|
|
namespace PHPCoord\CoordinateOperation; |
10
|
|
|
|
11
|
|
|
use function cos; |
12
|
|
|
use PHPCoord\Datum\Datum; |
13
|
|
|
use PHPCoord\UnitOfMeasure\Angle\Angle; |
14
|
|
|
use PHPCoord\UnitOfMeasure\Angle\Radian; |
15
|
|
|
use PHPCoord\UnitOfMeasure\Length\Length; |
16
|
|
|
use PHPCoord\UnitOfMeasure\Length\Metre; |
17
|
|
|
use function sin; |
18
|
|
|
use function sqrt; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* A geographic point w/out a CRS. |
22
|
|
|
* @internal |
23
|
|
|
*/ |
24
|
|
|
class GeographicValue |
25
|
|
|
{ |
26
|
|
|
private Radian $latitude; |
27
|
|
|
|
28
|
|
|
private Radian $longitude; |
29
|
|
|
|
30
|
|
|
private ?Metre $height; |
31
|
|
|
|
32
|
|
|
private Datum $datum; |
33
|
|
|
|
34
|
28 |
|
public function __construct(Angle $latitude, Angle $longitude, ?Length $height, Datum $datum) |
35
|
|
|
{ |
36
|
28 |
|
$this->latitude = $latitude->asRadians(); |
37
|
28 |
|
$this->longitude = $longitude->asRadians(); |
38
|
28 |
|
$this->datum = $datum; |
39
|
|
|
|
40
|
28 |
|
if ($height) { |
41
|
17 |
|
$this->height = $height->asMetres(); |
42
|
|
|
} |
43
|
28 |
|
} |
44
|
|
|
|
45
|
25 |
|
public function getLatitude(): Radian |
46
|
|
|
{ |
47
|
25 |
|
return $this->latitude; |
48
|
|
|
} |
49
|
|
|
|
50
|
25 |
|
public function getLongitude(): Radian |
51
|
|
|
{ |
52
|
25 |
|
return $this->longitude; |
53
|
|
|
} |
54
|
|
|
|
55
|
7 |
|
public function getHeight(): ?Metre |
56
|
|
|
{ |
57
|
7 |
|
return $this->height; |
58
|
|
|
} |
59
|
|
|
|
60
|
13 |
|
public function asGeocentricValue(): GeocentricValue |
61
|
|
|
{ |
62
|
13 |
|
$a = $this->datum->getEllipsoid()->getSemiMajorAxis()->asMetres()->getValue(); |
63
|
13 |
|
$e2 = $this->datum->getEllipsoid()->getEccentricitySquared(); |
64
|
13 |
|
$latitude = $this->latitude->getValue(); |
65
|
13 |
|
$longitude = $this->longitude->getValue() - $this->datum->getPrimeMeridian()->getGreenwichLongitude()->asRadians()->getValue(); |
66
|
13 |
|
$h = isset($this->height) ? $this->height->getValue() : 0; |
|
|
|
|
67
|
|
|
|
68
|
13 |
|
$nu = $a / sqrt(1 - $e2 * (sin($latitude) ** 2)); |
69
|
13 |
|
$x = ($nu + $h) * cos($latitude) * cos($longitude); |
70
|
13 |
|
$y = ($nu + $h) * cos($latitude) * sin($longitude); |
71
|
13 |
|
$z = ((1 - $e2) * $nu + $h) * sin($latitude); |
72
|
|
|
|
73
|
13 |
|
return new GeocentricValue(new Metre($x), new Metre($y), new Metre($z), $this->datum); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.