1 | <?php |
||
26 | class LOC implements RdataInterface |
||
27 | { |
||
28 | use RdataTrait; |
||
29 | |||
30 | const TYPE = 'LOC'; |
||
31 | const TYPE_CODE = 29; |
||
32 | const LATITUDE = 'LATITUDE'; |
||
33 | const LONGITUDE = 'LONGITUDE'; |
||
34 | const FORMAT_DECIMAL = 'DECIMAL'; |
||
35 | const FORMAT_DMS = 'DMS'; |
||
36 | |||
37 | /** |
||
38 | * @var float|null |
||
39 | */ |
||
40 | private $latitude; |
||
41 | |||
42 | /** |
||
43 | * @var float|null |
||
44 | */ |
||
45 | private $longitude; |
||
46 | |||
47 | /** |
||
48 | * @var float |
||
49 | */ |
||
50 | private $altitude = 0.0; |
||
51 | |||
52 | /** |
||
53 | * @var float |
||
54 | */ |
||
55 | private $size = 1.0; |
||
56 | |||
57 | /** |
||
58 | * @var float |
||
59 | */ |
||
60 | private $horizontalPrecision = 10000.0; |
||
61 | |||
62 | /** |
||
63 | * @var float |
||
64 | */ |
||
65 | private $verticalPrecision = 10.0; |
||
66 | |||
67 | /** |
||
68 | * @param float $latitude |
||
69 | */ |
||
70 | 13 | public function setLatitude(float $latitude): void |
|
74 | |||
75 | /** |
||
76 | * @param string $format |
||
77 | * |
||
78 | * @return float|string|null |
||
79 | */ |
||
80 | 6 | public function getLatitude(string $format = self::FORMAT_DECIMAL) |
|
88 | |||
89 | /** |
||
90 | * @param float $longitude |
||
91 | */ |
||
92 | 13 | public function setLongitude(float $longitude): void |
|
96 | |||
97 | /** |
||
98 | * @param string $format |
||
99 | * |
||
100 | * @return float|string|null |
||
101 | */ |
||
102 | 6 | public function getLongitude(string $format = self::FORMAT_DECIMAL) |
|
110 | |||
111 | /** |
||
112 | * @param float $altitude |
||
113 | * |
||
114 | * @throws \OutOfRangeException |
||
115 | */ |
||
116 | 15 | public function setAltitude(float $altitude): void |
|
124 | |||
125 | /** |
||
126 | * @return float |
||
127 | */ |
||
128 | 4 | public function getAltitude(): float |
|
132 | |||
133 | /** |
||
134 | * @param float $horizontalPrecision |
||
135 | * |
||
136 | * @throws \OutOfRangeException |
||
137 | */ |
||
138 | 15 | public function setHorizontalPrecision(float $horizontalPrecision): void |
|
146 | |||
147 | /** |
||
148 | * @return float |
||
149 | */ |
||
150 | 4 | public function getHorizontalPrecision(): float |
|
154 | |||
155 | /** |
||
156 | * @param float $size |
||
157 | * |
||
158 | * @throws \OutOfRangeException |
||
159 | */ |
||
160 | 15 | public function setSize(float $size): void |
|
168 | |||
169 | /** |
||
170 | * @return float |
||
171 | */ |
||
172 | 4 | public function getSize(): float |
|
176 | |||
177 | /** |
||
178 | * @param float $verticalPrecision |
||
179 | * |
||
180 | * @throws \OutOfRangeException |
||
181 | */ |
||
182 | 15 | public function setVerticalPrecision(float $verticalPrecision): void |
|
190 | |||
191 | /** |
||
192 | * @return float |
||
193 | */ |
||
194 | 4 | public function getVerticalPrecision(): float |
|
198 | |||
199 | /** |
||
200 | * {@inheritdoc} |
||
201 | */ |
||
202 | 5 | public function toText(): string |
|
214 | |||
215 | /** |
||
216 | * Determine the degree minute seconds value from decimal. |
||
217 | * |
||
218 | * @param float $decimal |
||
219 | * @param string $axis |
||
220 | * |
||
221 | * @return string |
||
222 | */ |
||
223 | 7 | private function toDms(float $decimal, string $axis = self::LATITUDE): string |
|
236 | |||
237 | /** |
||
238 | * {@inheritdoc} |
||
239 | */ |
||
240 | 1 | public function toWire(): string |
|
252 | |||
253 | 1 | private static function numberToExponentValue(float $num): int |
|
260 | |||
261 | 1 | private static function exponentValueToNumber(int $val): float |
|
268 | |||
269 | /** |
||
270 | * Transform a DMS string to a decimal representation. Used for LOC records. |
||
271 | * |
||
272 | * @param int $deg Degrees |
||
273 | * @param int $min Minutes |
||
274 | * @param float $sec Seconds |
||
275 | * @param string $hemisphere Either 'N', 'S', 'E', or 'W' |
||
276 | * |
||
277 | * @return float |
||
278 | */ |
||
279 | 1 | public static function dmsToDecimal(int $deg, int $min, float $sec, string $hemisphere): float |
|
285 | |||
286 | /** |
||
287 | * {@inheritdoc} |
||
288 | * |
||
289 | * @return LOC |
||
290 | */ |
||
291 | 1 | public static function fromText(string $text): RdataInterface |
|
306 | |||
307 | /** |
||
308 | * {@inheritdoc} |
||
309 | * |
||
310 | * @return LOC |
||
311 | */ |
||
312 | 1 | public static function fromWire(string $rdata): RdataInterface |
|
326 | } |
||
327 |