1 | <?php |
||
14 | class Cartesian |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * X |
||
19 | * @var float |
||
20 | */ |
||
21 | protected $x; |
||
22 | |||
23 | /** |
||
24 | * Y |
||
25 | * @var float |
||
26 | */ |
||
27 | protected $y; |
||
28 | |||
29 | /** |
||
30 | * Z |
||
31 | * @var float |
||
32 | */ |
||
33 | protected $z; |
||
34 | |||
35 | /** |
||
36 | * Reference ellipsoid used in this datum |
||
37 | * @var RefEll |
||
38 | */ |
||
39 | protected $refEll; |
||
40 | |||
41 | /** |
||
42 | * Cartesian constructor. |
||
43 | * @param float $x |
||
44 | * @param float $y |
||
45 | * @param float $z |
||
46 | * @param RefEll $refEll |
||
47 | */ |
||
48 | 12 | public function __construct($x, $y, $z, RefEll $refEll) |
|
49 | { |
||
50 | 12 | $this->setX($x); |
|
51 | 12 | $this->setY($y); |
|
52 | 12 | $this->setZ($z); |
|
53 | 12 | $this->setRefEll($refEll); |
|
54 | 12 | } |
|
55 | |||
56 | /** |
||
57 | * String version of coordinate. |
||
58 | * @return string |
||
59 | */ |
||
60 | 1 | public function __toString() |
|
61 | { |
||
62 | 1 | return "({$this->x}, {$this->y}, {$this->z})"; |
|
63 | } |
||
64 | |||
65 | /** |
||
66 | * @return float |
||
67 | */ |
||
68 | 11 | public function getX() |
|
72 | |||
73 | /** |
||
74 | * @param float $x |
||
75 | */ |
||
76 | 12 | public function setX($x) |
|
80 | |||
81 | /** |
||
82 | * @return float |
||
83 | */ |
||
84 | 11 | public function getY() |
|
88 | |||
89 | /** |
||
90 | * @param float $y |
||
91 | */ |
||
92 | 12 | public function setY($y) |
|
96 | |||
97 | /** |
||
98 | * @return float |
||
99 | */ |
||
100 | 11 | public function getZ() |
|
104 | |||
105 | /** |
||
106 | * @param float $z |
||
107 | */ |
||
108 | 12 | public function setZ($z) |
|
112 | |||
113 | /** |
||
114 | * @return RefEll |
||
115 | */ |
||
116 | 1 | public function getRefEll() |
|
117 | { |
||
118 | 1 | return $this->refEll; |
|
119 | } |
||
120 | |||
121 | /** |
||
122 | * @param RefEll $refEll |
||
123 | */ |
||
124 | 12 | public function setRefEll($refEll) |
|
128 | |||
129 | /** |
||
130 | * Convert these coordinates into a latitude, longitude |
||
131 | * Formula for transformation is taken from OS document |
||
132 | * "A Guide to Coordinate Systems in Great Britain" |
||
133 | * |
||
134 | * @return LatLng |
||
135 | */ |
||
136 | 9 | public function toLatitudeLongitude() |
|
157 | |||
158 | /** |
||
159 | * Convert a latitude, longitude height to x, y, z |
||
160 | * Formula for transformation is taken from OS document |
||
161 | * "A Guide to Coordinate Systems in Great Britain" |
||
162 | * |
||
163 | * @param LatLng $latLng |
||
164 | * @return Cartesian |
||
165 | */ |
||
166 | 9 | public static function fromLatLong(LatLng $latLng) |
|
181 | |||
182 | /** |
||
183 | * Transform the datum used for these coordinates by using a Helmert Transform |
||
184 | * @param RefEll $toRefEll |
||
185 | * @param float $tranX |
||
186 | * @param float $tranY |
||
187 | * @param float $tranZ |
||
188 | * @param float $scale |
||
189 | * @param float $rotX rotation about x-axis in radians |
||
190 | * @param float $rotY rotation about y-axis in radians |
||
191 | * @param float $rotZ rotation about z-axis in radians |
||
192 | * @return mixed |
||
193 | */ |
||
194 | 10 | public function transformDatum(RefEll $toRefEll, $tranX, $tranY, $tranZ, $scale, $rotX, $rotY, $rotZ) |
|
206 | } |
||
207 |